Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBI Connect problems

Status
Not open for further replies.

netman4u

Technical User
Joined
Mar 16, 2005
Messages
176
Location
US
Hello all,

I am having some problems connecting to an Oracle DB via the DBI mod. I have Both the DBI and DBD::Oracle installed ok as I checked with the ppm "query" command.

I have the Oracle client set up ok as I can connect through Oracle net manager to my DB no problem.

Here is my code. It is right out of the CPAN mod description:

Code:
my $orauser = "xxxx";
my $orapass = "xxxx";
use DBI;
#use DBD::Oracle;
use strict;
use warnings;
my $name;
my $phone;
my $data_source = 'dbi::Oracle:binvdp01';
  my $dbh = DBI->connect($data_source, $orauser, $orapass)
      or die "Can't connect to $data_source: $DBI::errstr";

  my $sth = $dbh->prepare( q{
	select T1.SVALUE, T2.SVALUE from twtpropvalues T1, twtpropvalues T2 where 
	T1.PROPID=(select ID from twtproperties where WID='00000000000000000000000000000001') 
	and T2.PROPID=(select ID from twtproperties where WID='72B1577C795AB24888F4462B18D8F42D') 
	and T1.INSID=T2.INSID; 
  }) or die "Can't prepare statement: $DBI::errstr";

  my $rc = $sth->execute
      or die "Can't execute statement: $DBI::errstr";

  print "Query will return $sth->{NUM_OF_FIELDS} fields.\n\n";
  print "Field names: @{ $sth->{NAME} }\n";

  while (($name, $phone) = $sth->fetchrow_array) {
      print "$name: $phone\n";
  }
# check for problems which may have terminated the fetch early
  die $sth->errstr if $sth->err;

  $dbh->disconnect;

It cannot even connect. Here is my output:

Code:
D:\Stage>db_conn_test.pl
Can't connect to data source Oracle:binvdp01, no database driver specified and DBI_DSN env var not set at D:\Stage\db_conn_test.pl line 40

I even tried to create and ENVAR DBI_DSN. No go.

Any help is appriciated.

Nick

If at first you don't succeed, don't try skydiving.
 
Ok, found the problem here:

Code:
Old Code:

my $data_source = 'dbi::Oracle:binvdp01';

Code:
New Code:

my $data_source = "dbi:Oracle:binvdp01";


If at first you don't succeed, don't try skydiving.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top