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

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

Replies are listed 'Best First'.
Re^6: execute Oracle anonymous procedure using perl
by Anonymous Monk on Feb 05, 2016 at 12:08 UTC
    Thank You poj. This works.