Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

i'm using Perl 5.8.3 with DBD:Oracle 1.15 and DBI 1.42, and i'm not able to get the following working:
Select a, cursor(select d, e from t2 where k = t1.b) cur from t1
when i call $sth->fetch, $sth->fetchrow_hashref or similiar i get the following error:
Field 2 has an Oracle type (116) which is not explicitly supported at .../Oracle.pm line 312
using $sth->bind_col(2, $cursor, {ora_type => ORA_RSET}); after calling $sth->execute isn't working either, same error.
I got DBI working with PL/SQL-functions that return a cursor, using bind_param_inout, but obviously i can't use that here. Is DBI not able to handle cursors in selects or am i doing something wrong?

Replies are listed 'Best First'.
Re: DBD::Oracle - Cursor in Select
by mifflin (Curate) on Jul 28, 2004 at 13:43 UTC
    Doesn't look like that is supported.
    try reworking your query as a join.
    Something like ...
    Select t1.a, t2.d, t2.e from t2, t2 where t2.k = t1.b
Re: DBD::Oracle - Cursor in Select
by etcshadow (Priest) on Jul 28, 2004 at 16:17 UTC
    The DBD::Oracle docs only refer to being able to bind cursors in PL/SQL blocks. Could very well be that cursors as return values from select statements just aren't supported (yet). I'm just guessing, here, but perhaps the reason this is done is so because a fetchall_* (or selectall_*, or anything similar) could result in a vast number of open cursors. Considering that a typical init.ora limits the number of open cursors to a few hundred, this would be a very bad thing.

    Of course, you could always just get your own cursor for each row:

    my $sth = $dbh->prepare("Select a, b from t1") or die "..."; $sth->execute or die "..."; while (my $row = $sth->fetchrow_arrayref) { my $cursor = $dbh->prepare("select d, e from t2 where k = ?"); $cursor->execute($row->[1]); # t1.b .... }
    Of course, anyone who's binding cursors probably already knows this :-D
    ------------ :Wq Not an editor command: Wq