Note: The TNS name of the database may not be the same as the DSN name (actually, when you configured the DSN entry, you placed the TNS name in the server area.)
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::er +r.']'; #-- 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::e +rrstr.' - '.$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
I hope this helps...
In reply to Re: Problem getting data from win32::ODBC connection to oracle
by Rhose
in thread Problem getting data from win32::ODBC connection to oracle
by RuneK
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |