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