in reply to Re: execute Oracle anonymous procedure using perl
in thread execute Oracle anonymous procedure using perl

Thanks for the response. I tried this but I am receiving below error message. DBD::Oracle::st execute failed: ORA-06502: PL/SQL: numeric or value error ORA-06512: at line 1 (DBD ERROR: OCIStmtExecute) for Statement "BEGIN :now := CURRENT_TIMESTAMP ; END;" with ParamValues: :now='' at t.pl line 16.
  • Comment on Re^2: execute Oracle anonymous procedure using perl

Replies are listed 'Best First'.
Re^3: execute Oracle anonymous procedure using perl
by poj (Abbot) on Feb 04, 2016 at 22:26 UTC

    What are your OS, Perl and Oracle versions ?

    poj
        Try this modified code. Procedures don't have to return values but I have done it in these examples to show the procedure is being executed.

        #!perl use strict; use DBD::Oracle; use DBD::Oracle qw(:ora_types); runNoReturn("BEGIN NULL; END;"); runAndReturn("BEGIN :out := CONCAT('Hello ',USER) ; END;"); runAndReturn("BEGIN :out := CURRENT_DATE ; END;"); runAndReturn(" BEGIN :out := TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS'); END;"); sub runNoReturn { my $procT = shift; my $dbh1=DBI->connect( 'dbi:Oracle:host=localhost;sid=xe','user','pwd', {RaiseError => 1 , PrintError => 0} ); $dbh1->do($procT); $dbh1->disconnect; print "Anon $procT finished\n"; } sub runAndReturn { my $procT = shift; my $dbh1=DBI->connect( 'dbi:Oracle:host=localhost;sid=xe','user','pwd', {RaiseError => 1 , PrintError => 0} ); my $out = ''; my $sth1 = $dbh1->prepare($procT); $sth1->bind_param_inout(":out",\$out,50,{ora_type => ORA_VARCHAR2}); $sth1->execute; $dbh1->disconnect; print "$out\n"; }
        poj
      OS is windows 7, perl v5.16.3 and Oracle is 11g

        Ok, are you using ODBC ?

        Try

        runThis("BEGIN :now  := TO_CHAR(CURRENT_TIMESTAMP) ; END;");