Hi Geoffrey, > you don't need to set $ENV{'ORACLE_SID'} set at startup, just > $ENV{'ORACLE_HOME'} if you make the instance name part of the DBI > connect string:
That's great!! I set only $ENV{'ORACLE_HOME'} and $ENV{'NLS_LANG'} in startup.pl . And I changed my script as following.(no %ENV setting) This script worked fine! -------- my $sid = 'ynt0'; my $dsn = 'dbi:Oracle:'; my $user = 'username/password'; my $password = ''; $dbh = DBI->connect("$dsn$sid", $user, $password) or die "Cannot connect: ".$DBI::errstr; -------- Thank you for your advice! Atsushi ----- Original Message ----- From: "Geoffrey Young" <[EMAIL PROTECTED]> To: "Atsushi Fujita" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, August 22, 2002 9:20 PM Subject: Re: mod_perl2 & DBD::Oracle problem > > > Atsushi Fujita wrote: > > > Hi all, > > > > Few weeks ago, I posted a problem about DBD::Oracle as following. > > > [snip] > > > > > > > > # add by atsushi 2002/08/22 > > $ENV{'ORACLE_HOME'} = '/u01/app/oracle/product/9.0.1'; > > $ENV{'ORACLE_SID'} = 'ynt0'; > > $ENV{'NLS_LANG'} = 'japanese_japan.ja16euc'; > > > > 1; > > -------- > > > > > > But..., I want to change $ENV{'ORACLE_SID'} dynamically, because I have many > > DB to connect. > > Currently my perl program handles the target DB SID by user http request. > > I hope we can change %ENV for DBD::Oracle on perl script in the future. > > > > Thank you Stas for helping this matter! > > > > > you don't need to set $ENV{'ORACLE_SID'} set at startup, just > $ENV{'ORACLE_HOME'} if you make the instance name part of the DBI > connect string: > > my $DBASE='ynto'; > my $DBUSER='foo'; > my $DBPASS='bar'; > > > my $dbh = DBI->connect("dbi:Oracle:$DBASE", $DBUSER, $DBPASS, > {RaiseError => 1, AutoCommit => 0, PrintError => 1}) or die > $DBI::errstr; > > see the DBD::Oracle manpage or the cheetah book for more info about > Oracle connect strings - you can put just about anything in them, even > something like > > $dbh = DBI->connect('dbi:Oracle:host=foobar;sid=ORCL;port=1521', > 'scott/tiger', '') > > or > > $dbh = DBI->connect('dbi:Oracle:', q{scott/tiger@(DESCRIPTION= > (ADDRESS=(PROTOCOL=TCP)(HOST= foobar)(PORT=1521)) > (CONNECT_DATA=(SID=ORCL)))}, "") > > HTH > > --Geoff > > > > >