Advertisement
kijato

perl_dbi_dbd-oracle_test.pl

May 21st, 2018
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.71 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use DBI;
  4. use strict;
  5. use vars qw($dbh $sth);
  6.  
  7. BEGIN {
  8.     #$ENV{ORACLE_HOME} = '/home/oracle/product/10.x.x';
  9.     #$ENV{TWO_TASK}    = 'DB';
  10.     #$ENV{'DBI_TRACE'}='0';
  11. }
  12. my $host='localhost';
  13. my $sid='orcl';
  14.  
  15. DBI->trace(15);
  16. #DBI->trace( 1, 'my_program.trace' );
  17.  
  18. # get a database handle
  19. $dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid;port=1521", 'system', 'scott');
  20.  
  21. # get a statement handle
  22. #$sth=$dbh->prepare('SELECT current_date FROM dual');
  23. $sth=$dbh->prepare('SELECT nev FROM table1');
  24.  
  25. # execute the statement handle
  26. $sth->execute();
  27.  
  28. # loop through the results
  29. while (my ($value) = $sth->fetchrow())
  30. {
  31.     print " $value \n";
  32. }
  33.  
  34. $sth->finish();
  35. $dbh->disconnect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement