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

Oracle database connection

by krachen (Novice)
on Dec 06, 2004 at 21:36 UTC ( [id://412762]=perlquestion: print w/replies, xml ) Need Help??

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

I'm building a perl script using CGI and DBI. I want to display data selected from an Oracle database in an browser. I've already done it with Mysql. What module do I add to the script to set Oracle home and the other environment variables that I need? The DBD link showed me what I needed. You guys rock.

Replies are listed 'Best First'.
Re: Oracle database connection
by dragonchild (Archbishop) on Dec 07, 2004 at 00:41 UTC
    You will want to use DBD::Oracle and set, at the very least, $ENV{ORACLE_HOME}. Possibly $ENV{NLS_SETTINGS} as well (or whatever it is). The DBD::Oracle POD is very good at explaining it.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: Oracle database connection
by Errto (Vicar) on Dec 07, 2004 at 04:00 UTC
    To further elaborate (since I did this for the first time recently), my fellow monks are correct that DBD::Oracle is the module you want. In order to install it, however, you must already have set up a full Oracle client installation, including specifically the OCI (Oracle Call Interface) drivers for your platform. You also need to set the $ORACLE_HOME environment variable before trying to even install DBD::Oracle. This tripped me up initially because I had worked with Java on Oracle before, and in Java you have a choice of using OCI or the "thin" driver, which is pure Java and requires no ORACLE_HOME. But there is no pure Perl driver for Oracle, AFAIK.
      But there is no pure Perl driver for Oracle, AFAIK.

      You are absolutely correct, because there are no Oracle drivers outside of C/C++ and Java. So, there aren't any pure Haskell drivers, either.

      Installing DBD::Oracle is probably the hardest single module install I've ever done, with the possible exception of DBD::mysql.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        Installing DBD::Oracle is probably the hardest single module install I've ever done

        It being so close to Christmas, here is my Oracle/Perl wishlist:

        Things are supposed to get lot easier once Oracle releases the overdue Instant Client SDK (not sure when this will be, though). Then, you can just install a few RPMs and DBD::Oracle should be able to build out of the box, without much fiddling with the build files and parameters.

        And things are also supposed to get even more easy with Perl6/Parrot where the DBD::Oracle does not even need a (C) compiler anymore to install, relying on Parrot's cool dynamic library loaders. But here we are not talking about this year's Christmas...

Re: Oracle database connection
by Grygonos (Chaplain) on Dec 06, 2004 at 21:46 UTC
      You can do something like this for the script:
      BEGIN { $ENV{ORACLE_HOME} = "E:\\Oracle\\Ora92\\"; } # See man page for DBD::Oracle and seeting of ENV variables.

      In this case I was on a Windoze box, but it works the same on *nix

      To make DBD::Oracle work I needed to have Oracle installed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://412762]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-06-13 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.