use strict; use DBI; #-- Define local constants use constant TRUE => 1; use constant FALSE => 0; use constant ORAUSER => 'scott'; use constant ORAPASS => 'tiger'; use constant ORATNS => 'clamon'; #-- Define local variables my $gDBHandle; my $gSQLCmd; my $gSQLHandle; my @gFields; #-- Connect to the database $gDBHandle = DBI->connect ( 'dbi:Oracle:' . ORATNS, ORAUSER, ORAPASS, { AutoCommit => FALSE, PrintError => FALSE, RaiseError => FALSE, } ) || die 'Could not connect to Oracle ['.$DBI::errstr.' - '.$DBI::err.']'; #-- Get the data $gSQLCmd = 'SELECT * FROM emp WHERE empno = ?'; $gSQLHandle = $gDBHandle->prepare ( $gSQLCmd ) || die 'Error with SQL statement ['.$DBI::errstr.' - '.$DBI::err.']'; $gSQLHandle->execute(7900) || die 'Error with SQL statement ['.$DBI::errstr.' - '.$DBI::err.']'; while (@gFields = $gSQLHandle->fetchrow_array) { print 'Row: ',$gFields[0],"\t",$gFields[1],"\t",$gFields[2],"\n"; } #-- Close the database connection $gDBHandle->disconnect(); #-- Exit exit; #-- End of sample