Notes for How To Use Perl's DBI Modules See http://dbi.perl.org or http://search.cpan.org/perldoc?DBI for the documentation. ---------------------------------------------------------------------------------------- Some common variable names and their implied content, $dbh Database handle object $sth Statement handle object $drh Driver handle object (rarely seen or used in applications) $h Any of the handle types above ($dbh, $sth, or $drh) $rc General Return Code (boolean: true=ok, false=error) $rv General Return Value (typically an integer) @ary List of values returned from the database, typically a row of data $rows Number of rows processed (if available, else -1) $fh A filehandle ---------------------------------------------------------------------------------------- From what I can tell, despite seeing it in Dale's old save_* code and in various fcgi-bin Perl programs, one does not have to set $ENV{DB2DIR}="/home/inst1/sqllib"; $ENV{INSTHOME}="/home/inst1"; $ENV{PATH}.=":/home/inst1/sqllib/bin:/home/inst1/sqllib/adm:/home/inst1/sqllib/misc"; $ENV{LD_LIBRARY_PATH}.=":/home/inst1/sqllib/lib"; in order to use DBI. All you really need is $ENV{DB2INSTANCE}="inst1"; # Normally or $ENV{DB2INSTANCE}="caeadmin"; # On most dephds0nn systems (not 59 or 61) or $ENV{DB2INSTANCE}="db2inst1"; # On dephds069 ---------------------------------------------------------------------------------------- $dbh->rows is suppose to return the number of rows affected by the last command, or -1 if the number of rows is not known or not available, but there's this caveat for select statements, Generally, you can only rely on a row count after a non-SELECT execute (for some specific operations like UPDATE and DELETE), or after fetching all the rows of a SELECT statement. For SELECT statements, it is generally not possible to know how many rows will be returned except by fetching them all. Some drivers will return the number of rows the application has fetched so far, but others may return -1 until all rows have been fetched. so it's basically worthless.