renu has asked for the wisdom of the Perl Monks concerning the following question:

I have a doubt in DBD module. If there are two applications running in a single machine and the ORACLE_SID for two applications are "db1" and "db2".To compile and install the DBD, i have used "db1" for ORACLE_SID and installed. Will this module work for the other application whose ORACLE_SID is "db2"?
Thanks in advance
Renu.

Replies are listed 'Best First'.
Re: DBD module.
by dragonchild (Archbishop) on Apr 21, 2006 at 02:27 UTC
    You tested it using db1 for ORACLE_SID. When you start the program, it will look at the ORACLE_SID environment variable. You can even set it in a BEGIN block, if you want.

    In short - yes.


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      It is working fine for first application whose ORACLE_SID=db1. And not working for other application(ORACLE_SID=db2)
        You know - saying something like that in your original post would have been helpful and saved you a day of waiting for the right answer.

        Have you checked to see what $ENV{ORACLE_SID} is set to? That's what DBD::Oracle is looking for. If you absolutely need to, you can do something like:

        BEGIN { $ENV{ORACLE_SID} = 'db2'; } use DBI; my $dbh = DBI->connect( .. );

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: DBD module.
by Mr. Muskrat (Canon) on Apr 21, 2006 at 16:44 UTC
    As dragonchild said, you can set $ENV{ORACLE_SID} however you don't have to do so. You can add the SID to your connect statement (see DBD::Oracle).
    # set your $host, $sid, $user and $passwd then connect my $dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid", $user, $passw +d);