Gourab Sengupta Gourab Sengupta - 6 months ago 19
Perl Question

Calling a stored proc from perl

I am running this subroutine from the main script.

print "parameter passed: $_[0]";
my $connect_string = 'test/test@testdb';
my $sqlplus_settings = '';
my $task = '';
my $result = qx { sqlplus $connect_string << EOF
$sqlplus_settings exec {pkgname.procedure($_[0], 'abc',$task);
#exit;
EOF


When it is getting called from the main script
{sub($var)}
, it is printing the first line with the input parameter. But the procedure is not getting executed.

Answer

As mentioned by user @choroba in the comments above, the best way IMHO is to use Perl's DBI module.

Here is an example of calling your stored procedure that would work with Oracle:

$dbh->do("BEGIN your_procedure; END;");

And here is a link to help you get started with the DBI module:

Perl DBI

HTH