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

I am using Windows7. Now I am using connectstring that you have provided, and included to_char on top of timestamp. but I still get same error.

DBD::Oracle::st execute failed: ORA-06502: PL/SQL: numeric or value error: chara cter string buffer too small ORA-06512: at line 1 (DBD ERROR: OCIStmtExecute) for Statement "BEGIN :now := TO_CHAR(CURRENT_TIMESTAMP) ; END;" with ParamValues: :now='' at t.pl line 16.

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

Replies are listed 'Best First'.
Re^5: execute Oracle anonymous procedure using perl
by poj (Abbot) on Feb 05, 2016 at 08:00 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.