Re: Connecting to a Oracle database with Perl

From: Sarah Yaksich <sarah_yaksich_at_hotmail.com>
Date: 1998/03/05
Message-ID: <34ff3b68.5814984_at_news.bne.aone.net.au>#1/1


Kevin,
I have included some code which connects to a database, performs a perform and then deals with the rows rturned by the query. It does this using oraperl. Therefore you need to put the line use Oraperl at the top of your perl script.

$ora=ora_login("$DevDatabase","$UserName","$OraclePassword") or carcit("Login failed\n$ora_errstr\n");

# Perform the query
#
$query=ora_open($ora,"select status from pvcs_distribute where project_name = $Application_sql and incident_number = $IncidentNumber_sql and user_promoting = $UserPromoting_sql and workfile_version = $WorkfileVersion_sql and dest_machine = $DestMachine_sql and application_user = $ApplicationUser_sql and actual_file = $ActualFile_sql and status in (\'pre\',\'post\',\'distribute\')") or carcit ("query failed\n$ora_errstr\n");

# While something was found in the query, deal with it #

while (($Status) = &ora_fetch($query)){

     if ($Status eq "pre") {
        update_status;
        insert_record;
        }
    elsif ($Status eq "post"){
        carcit ("Status of file being promoted is already at Post
Promote");
        }
    elsif ($Status eq "distribute"){
        carcit ("Status of file being promoted is already at
Distribute");
        }
    else{
        carcit ("Invalid status found in table pvcs_distribute");
        }

    }

Hope this helps
Sarah   

"Kevin Bass" <akil1_at_mindspring.com> wrote:

>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 Thu Mar 05 1998 - 00:00:00 CET

Original text of this message