Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Basic oraperl array question
On Thu, 03 Jun 1999 16:16:42 GMT, Jared Hecker <jhecker_at_iago.nac.net>
said:
>Given a statement that fetches multiple fields via &ora_fetch, is each
>field accessed as an element of an array? IOW, if I am fetching x rows
>with y fields, is each field referenced as $array[field position]?
Yes. ora_fetch returns a single row as a list where each element is a field from your query.
eg ...
$chiliHabits=&ora_open($dbh,
"SELECT userid, email, chilis_for_breakfast, ". " TO_CHAR(stamp,'DD-MON-YYYY HH24:MI:SS') ". " FROM users");
while(($userid, $email, $chilis, $stamp)=&ora_fetch($chiliHabits)) {
print "User no $userid ($email) ate $chilis chilis for ";
print "breakfast at $stamp.\n";
}
>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.
Try 'perldoc Oraperl'.
You need to open a cursor for every query you issue. You then ora_fetch each row one by one.
[Copying newsgroup posts to me by mail is considered rude]
--
David Cantrell, part-time Unix/perl/SQL/java techie
full-time chef/musician/homebrewer http://www.ThePentagon.com/NukeEmUpReceived on Thu Jun 03 1999 - 11:55:06 CDT
![]() |
![]() |