in reply to Saving array reference
..although I'm unclear as to why you can't just stop retrieving records after the first, or why you can't just use a 'limit 1' clause in your SQL.my $first = undef; while (my $record = $sth->fetchrow_arrayref) { unless (defined $first) { @{$first} = @{$record} } # other stuff }
Also my DBI doesn't define a fetch method on statement handles, only fetchrow_* and fetchall_*, so you may need to re-jig my example.
Update: jZed++ for pointing out fetch is an alias for fetchrow_arrayref. Thanks, I've managed to miss that in every reading of perldoc DBI.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Saving array reference
by jZed (Prior) on Apr 30, 2005 at 20:28 UTC | |
|
Re^2: Saving array reference
by Errto (Vicar) on May 01, 2005 at 01:34 UTC | |
|
Re^2: Saving array reference
by mhearse (Chaplain) on Apr 30, 2005 at 20:18 UTC |