Can some one please help me to let me know how to call a oracle subroutine in Perl script
I have a procedure already existing in oracle db. Say below
Case 1) return a ref cursor and accept a IN parameter.
CREATE OR REPLACE PROCEDURE procCursorExample(
cursorParam OUT SYS_REFCURSOR, userNameParam IN VARCHAR2)
IS
BEGIN
OPEN cursorParam FOR
SELECT * FROM DBUSER WHERE USERNAME = userNameParam;
END;
In SQL developer i can then execute it directly:
DECLARE
dbUserCursor SYS_REFCURSOR;
dbUserTable DBUSER%ROWTYPE;
BEGIN
procCursorExample(dbUserCursor,'mkyong');
LOOP
FETCH dbUserCursor INTO dbUserTable;
EXIT WHEN dbUserCursor%NOTFOUND;
dbms_output.put_line(dbUserTable.user_id);
END LOOP;
CLOSE dbUserCursor;
END;
Can some tell me how to invoke subroutine with argument through Perl script
Anwser
#!/usr/bin/perl
use warnings ;
use strict ;
use DBI;
print "Connecting to DB..";
my $dbh = DBI->connect('dbi:Oracle:xe', 'scott', 'tiger') or
die "Cannot connect to DB => " . DBI->errstr;
# prepare ????????
am not sure about prepare statement. Any help is highly appreciable.
Please read the documentation examples for calling stored procedures in Perl with DBD::Oracle, which is the driver you are using.
From this link specifically: