This discussion is archived
2 Replies Latest reply: Aug 29, 2011 7:30 AM by fac586 RSS

access oracle 10g xe with perl

449363 Newbie
Currently Being Moderated
I'm using ubuntu lucid as OS, oracle 10g xe as db and want to access the oracle db via perl.
Installed software:
libdbd-oracle-perl 1.21-2
libdbi-perl 1.609-1build1
perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
oracle-xe-universal 10.2.0.1-1.0
oracle-instantclient-basic 10.2.0.3-2

after using
#!/usr/bin/perl

my $ORACLE_HOME = "/usr/lib/oracle/xe/app/oracle/product/10.2.0/server";
my $ORACLE_SID="XE";

$ENV{ORACLE_HOME}=$ORACLE_HOME;
$ENV{ORACLE_SID}=$ORACLE_SID;
$ENV{PATH}="$ORACLE_HOME/bin";
# $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

use strict;
use DBI;
my $dbh = DBI->connect( 'dbi:Oracle:XE@localhost','scott','tiger',{ RaiseError => 1, AutoCommit => 0 }
                      ) || die "Database connection not made: $DBI::errstr";

$dbh->disconnect;
I get the error:
wucis@dell6400:~/perlora$ perl zugriff1.pl
DBI connect('XE@localhost','scott',...) failed: ORA-12154: TNS:could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach) at zugriff1.pl line 13
although sqlplus scott/tiger works properly

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points