Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Basic oraperl array question
In article <KTx53.667$m4.3117_at_nntp1>,
Jared Hecker <jhecker_at_iago.nac.net> wrote:
>Nothing in the Oraperl docs refers to this and I feel like I am writing
>way too many cursors and fetches to do something like this.
perldoc Oraperl
ora_fetch
Used in an array context, the value returned is an array containing the data, one element per field. Note that this will not work as expected:
#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect("dbi:Oracle:", "scott", "tiger", {RaiseError=>1});
my $sth = $dbh->prepare("SELECT ename, empno FROM emp");
$sth->execute();
#
my ($ename, $empno);
$sth->bind_columns(undef, \($ename, $empno));
while ($sth->fetchrow-arrayref) {
print $ename, $empno;
}
## or #my @row; #while (@row = $sth->fetchrow_array) { # print $row[0], $row[1]; #} ## or #my $row_ref; #while ($row_ref = $sth->fetchrow_hashref) { # print $row_ref->{"ENAME"}, $row_ref->{"EMPNO"}; #}
>If it is convenient, e-mail will reach me faster.
While faster and more convenient for you, email does nothing to help save
the world by sharing our answers and allowing them to be archived.
John
groenveld_at_acm.org
Received on Thu Jun 03 1999 - 14:06:24 CDT
![]() |
![]() |