Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Strange behaviour with DBD::Oracle

by Fairchild (Acolyte)
on Sep 04, 2011 at 11:06 UTC ( #924063=perlquestion: print w/replies, xml ) Need Help??
Fairchild has asked for the wisdom of the Perl Monks concerning the following question:


I am getting a very strange behaviour in trying to use DBD::Oracle to connect to a database. From the command line I can connect to a local database using TWO_TASK or ORACLE_SID so the link to the database is fine. However if I have a script of the following form:

$ENV{ORACLE_SID}="grumpy"; my $dbh = DBI->connect( "dbi:Oracle:","sneezy","sneezy" ); my @output = `echo hi`; printf "Job status: %d\n", $?; exit;

I get a job status of -1 although the command has run successfully. It doesn't matter what command I give it is always -1. If I replace $ENV{ORACLE_SID} with $ENV{TWO_TASK} = "grumpy" then the job status comes out with 0. So I am presuming that DBD::Oracle is polluting perl in some manner if the ORACLE_SID is set? Why though and is there a way to get the system to perform in a "normal" way.

The problem occurs on Red Hat Linux 5.6 (and on Solaris 10) in a 64-bit environment with Oracle 11g. I've tried both DBD::Oracle 1.20 and 1.27. Has anyone else had this problem? Thanks.


Replies are listed 'Best First'.
Re: Strange behaviour with DBD::Oracle
by kcott (Chancellor) on Sep 04, 2011 at 17:59 UTC

    Take a look at the DBI Dynamic Attributes section of DBI. Here you'll find $DBI::err, $DBI::errstr, $DBI::state and others: I suspect this is the type of information you're after (rather than $?).

    -- Ken

Re: Strange behaviour with DBD::Oracle
by Anonymous Monk on Sep 04, 2011 at 13:01 UTC
    That makes no kind of sense :) echo command success or failure has nothing DBI or oracle

      The oracle client is a fussy thing.

      You have to have the environemnt configured correctly. But, if you are running SUID root the environment is not available to you. Catch 22!

      My complany has packaged all of this mess away with RPM wrappers around the oracle instant clients that I cannot believe are not part of normal distributions.

      For shell folks

      echo -e "#Name: %{name}\n#Summary: %{summary}\n#Version: %{version}\ne +xport ORACLE_HOME=/usr/lib/oracle/%{version}/%{client_folder}\nexport + LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/lib/oracle/%{version}/%{clien +t_folder}/lib" >> "$RPM_BUILD_ROOT"%{_sysconfdir}/profile.d/oracle-en

      For http scripts

      echo -e "#Name: %{name}\n#Summary: %{summary}\n#Version: %{version}\nS +etEnv ORACLE_HOME /usr/lib/oracle/%{version}/client64\nSetEnv LD_LIBR +ARY_PATH /usr/lib/oracle/%{version}/client64/lib" >> "$RPM_BUILD_ROOT +"%{_sysconfdir}/httpd/conf.d/oracle-environment.conf

      For suid scripts

      cp tnsnames.ora "$RPM_BUILD_ROOT"%{_sysconfdir} echo -e "/usr/lib/oracle/%{version}/%{client_folder}/lib" > "$RPM_BUIL +D_ROOT"%{_sysconfdir}/ +conf ldconfig



      echo command success or failure has nothing DBI or oracle

      except that the example code uses Perl backticks and that can be affected by signal disposition.

        The code , as presented, doesn't mess with signals, and even if it did, echo still has nothing to do with DBI or DBD::Oracle

Re: Strange behaviour with DBD::Oracle
by mje (Curate) on Sep 05, 2011 at 08:20 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://924063]
Approved by ww
[Discipulus]: he eh latinos superstitious peoples..
[Discipulus]: here at my $work fuc**ing bas**ds proposed to everyone 20 free month of pay to leave
[Discipulus]: I expect a cut of 20% of emplyoment nexet year..
[choroba]: 20 months? :-o

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2018-05-23 20:52 GMT
Find Nodes?
    Voting Booth?