Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Basic oraperl array question
<blush> found the section. Thank you.
In comp.lang.perl.misc John D Groenveld <groenvel_at_cse.psu.edu> wrote:
> 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:
> If you switch from the emulation module to DBI, you can access those
> values in a multitude of ways. See perldoc DBI
> #!/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"};
> #}
> $sth->finish;
> $dbh->disconnect;
> >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
--
Jared Hecker | HWA Inc. - Oracle architecture and Administration jared_at_hwai.com | ** serving NYC and New Jersey **Received on Fri Jun 04 1999 - 10:25:49 CDT
![]() |
![]() |