Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

execute Oracle anonymous procedure using perl

by hs (Initiate)
on Feb 04, 2016 at 19:25 UTC ( [id://1154417]=perlquestion: print w/replies, xml ) Need Help??

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

Hello, I am trying to run a ORacle anonymous block using perl DBI, but I am receiving error as mentioned below. Please help..
sub runThis($procT) { my $dbh1=DBI->connect("dbi:ODBC:$db","$usr","$pass", {RaiseError => 1 , PrintError => 0} ); $sqlstmt1 = "BEGIN $procT END;"; $sth1 = $dbh1->do($sqlstmt1) or die $dbh1->errstr; $dbh1 -> disconnect; } runThis("BEGIN NULL; END;");
--------------------------------------- Error message:
DBD::ODBC::db do failed: [Oracle][ODBC][Ora]ORA-06550: line 1, column +7: PLS-00103: Encountered the symbol "END" when expecting one of the foll +owing:
---------------------------- Thanks

Replies are listed 'Best First'.
Re: execute Oracle anonymous procedure using perl
by NetWallah (Canon) on Feb 04, 2016 at 20:27 UTC
    Please use <code> tags , as described in Markup in the Monastery.

    You are effectively passing the command:

    BEGIN BEGIN NULL;END;END
    To oracle. This seems to generate an Oracle syntax error.

    To see what it does, run that using "sqlplus", and see if you get the same result.

            ...The words of the Prophets are written on the Facebook wall.

      Thanks for response. I am using ODBC as see in the DBI statement.
Re: execute Oracle anonymous procedure using perl
by poj (Abbot) on Feb 04, 2016 at 20:26 UTC
    #!perl use strict; use DBD::Oracle; runThis("BEGIN :now := CURRENT_TIMESTAMP ; END;"); sub runThis { my $procT = shift; my $dbh1=DBI->connect( 'dbi:Oracle:host=localhost;sid=xe','user','password', {RaiseError => 1 , PrintError => 0} ); my $now = ''; my $sth1 = $dbh1->prepare($procT); $sth1->bind_param_inout(":now",\$now,0); $sth1->execute; $dbh1->disconnect; print "time now is $now\n"; }
    poj

        What are your OS, Perl and Oracle versions ?

        poj
Re: execute Oracle anonymous procedure using perl
by mje (Curate) on Feb 08, 2016 at 10:14 UTC

    In ODBC you use '{call procname (arguments)}'.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-24 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found