Hi ,

if you want "sql-fields" separate you will have to select them separately,
o.K.?
First you will have to have e.g. DBI,
>> #!/usr/local/bin/perl
>>  use DBI;
 then you will need a driver for your db (e.g. dbi::db2 ) or use DBI::ODBC!
use DBD::DB2::Constants;
use DBD::DB2 qw($attrib_int $attrib_char $attrib_float
                 $attrib_date $attrib_ts);
Then you will need to connect to that database.
>> # Open a connection and set LongReadLen to maximum size of column
 >> $dbh = DBI->connect("dbi:DB2:$dbname","$user","$passwd", { LongReadLen
=> 102400 } );
>>  if (!defined($dbh)) { exit; }
 And then  select them
  by first define the sql-statement
>> $stmt = "Select tabschema,tabname from syscat.tables where tabschema
= 'Something ' ; ";
  by second prepare und third execute the statement
>>   my $sth = $dbh->prepare($stmt);
>>   $sth->execute();
  and finally fetch the results into local array's :
>>  my $stmt_array_result = $sth->fetchall_arrayref();
>>
>>  foreach my $row (@$stmt_array_result)
>>  {
>>   my ( $schema, $tabname ) = @$row;
>>      ...
>>   }
 and finally don't forget to close everything :
>> # close selection criteria cursor
>>  $sth->finish();
>>  close(OUTPUT);
>>  $dbh->disconnect();

Please note that this only one possibility to that job. after my '>>' you
just find one example for dbi with db2 like I use it, being still a
beginner with perl and dbi not knowing if there are better possibilitites,
but it works out for me!


Manfred Beilfuss


Deutsche Vermögensberatung AG


IT-Systemmanagement / DBA


Gutleutstraße 7
60329 Frankfurt


Tel.: +49 (69) 2384 - 639


Mailto:[EMAIL PROTECTED]





                                                                                       
                           
                    "Ramprasad"                                                        
                           
                    <[EMAIL PROTECTED]        An:     [EMAIL PROTECTED]                
                             
                    ore.co.in>             Kopie:                                      
                           
                                           Thema:  Re: How to get fields from a SQL DB 
one by one                 
                    15.10.2003                                                         
                           
                    14:05                                                              
                           
                                                                                       
                           
                                                                                       
                           




On Wed, 15 Oct 2003 12:11:43 +0530, Ramakrishna wrote:

> Hi,
>
> Can any one tell me How to get fields from a SQL Database.
> I need to get each field separately.
>
> Thanks in advance,
> Ramakrishna.S

Which database, Are U using DBI

Ram

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to