I wrote the following in perl but it is not running. Anything wrong with it?
Stored Procedure created in Oracle
CREATE OR REPLACE procedure select_pm (n_QC_DEPL_S1 in NUMBER)
is
n_PM_DEPL_S1 NUMBER(3);
begin
DBMS_OUTPUT.PUT_LINE (n_QC_DEPL_S1);
select PM_DEPL_S1 into n_PM_DEPL_S1 from EIP_SR_SECT_PERF
where QC_DEPL_S1 = n_QC_DEPL_S1;
DBMS_OUTPUT.PUT_LINE (n_QC_DEPL_S1);
end select_pm;
/
Perl program to get the results
#!/usr/bin/perl
use DBI;
use strict;
require 'insert_db_dev.pl';
require 'database_dev.pl';
require 'general_functions.pl';
open(LOGFILE, '> ..\\logs\\geraltan_stored_proc.txt') or die "Can't cr
+eate logfile!\n";
get_results();
sub get_results()
{
printlog("Connecting to database.");
#my $dbh=connect_db(get_user_passwd());
my $dbh = DBI->connect('dbi:Oracle:host=ABC;sid=ABC123;port=1521',
+ 'abc','abc');
printlog("Connected.");
my $rv;
eval {
my $func = $dbh->prepare(q{ BEGIN :cursor := select_pm( parame
+ter1_in => :parameter1); END; });
$func->bind_param(":parameter1", '2');
$func->bind_param_inout(":cursor ", \$rv, 0, { ora_type => ORA
+_RSET});
$func->execute;
$func->finish;
$dbh->commit;
}
if( $@ ) {
warn "Execution of stored procedure failed: $DBI::errstr\n";
$dbh->rollback;
}
printlog("Execution of stored procedure returned $rv\n");
while(my $hashRef = $rv->fetchrow_hashref)
{
foreach(keys %$hashRef)
{
printlog("$_ is $hashRef->{$_}\n");
}
}
$rv->finish;
printlog("Disconnecting from database...");
$dbh->disconnect;
printlog("Disconnected.");
}
sub printlog($)
{
my $msg=shift;
print $msg,"\n";
print LOGFILE $msg,"\n";
}
close LOGFILE;
|