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

What are your OS, Perl and Oracle versions ?

poj
  • Comment on Re^3: execute Oracle anonymous procedure using perl

Replies are listed 'Best First'.
Re^4: execute Oracle anonymous procedure using perl
by Anonymous Monk on Feb 04, 2016 at 23:11 UTC
      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
        Thank You poj. This works.
Re^4: execute Oracle anonymous procedure using perl
by Anonymous Monk on Feb 04, 2016 at 22:45 UTC
    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;");