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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.