2008年3月4日 星期二

Perl DBI Calling Oracle Procedure

How does one invoke stored procedures with DBI?
There is currently no standard way to call stored procedures with DBI. However, if you have created a stored procedure within an Oracle database, you can use $dbh->do() to immediately execute the procedure:
$dbh->do("BEGIN myPackage.myProcedure; END;");

Or
Sample:
my $sth=$dbh_o->prepare("begin PRO_BID_QUEUE_TABLE(:in1,:int2,:T); end;");
$sth->bind_param("in1",20);
$sth->bind_param("in2",30);
my $result;
$sth->bind_param_inout("T",\$result,20);
$sth->execute();
$sth->commit();

CREATE OR REPLACE PROCEDURE
PRO_BID_QUEUE_TABLE( N1 IN NUMBER , N2 IN NUMBER , TOTAL OUT NUMBER)
IS
BEGIN
TOTAL := N1 + N2 ;
END;

沒有留言: