Hi, I'm hoping someone can help.
I am writing a script which I want to connect to different schemas and run some common queries. I've decided to use DBI for the connectivity and a hash to store the connectivity detail. My question is does DBI allow you to store all details in a single value or do you need to list each value separately.
Here is the code I am using
#!/usr/local/bin/perl -w use strict; use DBI; # for database connectivity my %db_conn = ( a_manager => "DBI:Oracle:host=hostname1;sid=ABCDB01;port=1300','a_m +anager','a_manager',", b_manager => "DBI:Oracle:host=hostname1;sid=ABCDB01;port=1300','b_m +anager','b_manager',", c_manager => "DBI:Oracle:host=hostname1;sid=ABCDB01;port=1300','c_m +anager','_manager',", d_manager => "DBI:Oracle:host=hostname1;sid=CBADB01;port=1300','d_m +anager','d_manager',", ); for my $owner (keys %db_conn) { print "Running $owner stats_table creation\n"; my $data_source = $db_conn{$owner}; print "$data_source\n"; my $query = qq ( select * from cat ); my $dbh = DBI->connect($data_source) or die "Couldn't connect to datab +ase: " . DBI->errstr; my $sth = $dbh->prepare($query) or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute() or die "Couldn't execute statement: " . $sth->errstr; }
I am currently getting the error ORA-24327: need explicit attach before authenticating a user (DBD ERROR: OCISessionBegin)
If, however, I pass the values as individual values it is successful
In reply to Using a HASH to store a DBI connection by chris01010
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |