Re: Connecting to a Oracle database with Perl

From: Craig Christman <christm_at_clark.net>
Date: 1998/03/07
Message-ID: <6drqmm$me$1_at_clarknet.clark.net>#1/1


Here's an example using the Perl extension DBI/DBD:

use strict;
use DBI;

my($SERVER_SID) =   "home";
my($USER_ID) =      "scott/tiger";
my($h,$dbh,$iCase);
my(_at_a);

$dbh = DBI->connect("dbi:Oracle:$SERVER_SID", $USER_ID, '', { RaiseError => 1, PrintError => 1, AutoCommit => 0} ) ; die "Unable to connect to Oracle\n$DBI::errstr\n" unless $dbh;

$iCase = 5;
$h = $dbh->prepare(qq(SELECT * FROM CDROM WHERE CASE_ID=$iCase')); die "Unable to open cursor:\n" . $dbh->errstr if !$h->execute; while ( _at_a=$h->fetchrow ) {

        foreach(_at_a)     {
                print "$_,";
        }
        print "\n";

}

$h->finish;

Kevin Bass wrote in message <6dl7ah$pus$4_at_camel20.mindspring.com>...
>How can I connect to an Oracle database and run a SQL statement in Perl
>using DBI, oraperl and/or any other method? Please give an example of a
>method(s) stated in prior sentence. [This is not for a class or any other
>instructor-based
>education.]
>
>
>Kevin
>
>
>
>
>
Received on Sat Mar 07 1998 - 00:00:00 CET

Original text of this message