Hi, guys,
Finally, I got it after lots of time spend searching for information on internet , consulting with administrator and lots of trials! And, it's quite simple once you get the important facts: one is to set oracle home to local oracle directory and set the SID to the remote machine's sid, another one is include the NLS package.
Here is the example perl script to use to connect oracle database on
cypress.
Everything else remains the same as if you are working on a local
machine' s
database. This means you use the same old way how you handle prepare,
execute
and examine the result set. Nothing in .cshrc file has to be changed
if you
don't need to use SQL*Plus. To use SQL*Plus, set the enviroment
variables as in
the BEGIN block and access with this command: sqlplus
username/password@cypress.cacs.louisiana.edu.
It should be working.
Any problem, email me.
Xiaoyang He
************************************example connection*****************
sub db_connect{
#builder a connection to oracle database
BEGIN{ #set enviroment variable in hash
$ENV{ORACLE_HOME} = '/pkgs2/oracle8.0.4/app/oracle/product/8.0.4';
$ENV{ORACLE_SID} = 'dmdb';
$ENV{ORA_NLS32} = '$ENV{ORACLE_HOME}/ocommon/nls/admin/data';
$ENV{TNS_ADMIN} = '/pkgs2/oracle8.0.4/app/oracle/product/8.0.5/network/admin';
}
#set userid and password
#my @data_sources=DBI->data_sources("Oracle");
my $user="yourLogId";
my $passwd="yourPassWord";
my $host="cypress.cacs.louisiana.edu";
my $port="1521";
my $db="dmdb";
#connect to the database
$dbc=DBI->connect("dbi:Oracle:host=$host;sid=$db;port=$port", $user, $passwd, {RaiseError=>1});
#report unsuccess connction
die" Couldn't connect to database" unless $dbc;
}
*****************End of example*****************************************