I'm writing a series of wrapper functions in Perl for some stored procedures in an Oracle 10 database. I'm using essentially the same code to retrieve the return values of two different procedures, and it works for one (returning an integer) but not the other (returning undef). I've called the PL/SQL code directly in the database and it behaves as expected; assuming that the problem is not in the database, what might cause this problem?
sub Create($$$) {
my $dbh = shift(@_);
my @parameters = @_;
my $return_value;
eval {
my $func = $dbh->prepare(q{
DECLARE
returned_cursor foo_CURSOR;
returned_row foo_view%ROWTYPE;
BEGIN
returned_cursor := foo.fn(
:parameter1,
);
FETCH returned_cursor INTO returned_row;
:id := returned_row.id;
END;
});
$func->bind_param(":parameter1", $parameters[1]);
$func->bind_param_inout(":id", \$return_value, 1);
$func->execute;
};
<error catching>
}
Basically it calls the stored procedure fn in the schema foo, which creates a row in foo, and returns a cursor to a row in foo_view. I then want to return the id from this row. $return_value is undef for one use of this block, but the correct if for another.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.