in reply to selectrow_hashref upper/lower case

First, see the FetchHashKeyName attribute in the DBI docs, and set it to 'NAME_lc' or 'NAME_uc' if you are going to use fetchrow_hashref.

Both fetchrow_arrayref and fetchrow_hashref return the same arrayref (I think the docs say that the behavior on the hashref may change to do this, so you may want to change for forward compatibility). Ovid's answer above is okay since he is making a copy of the array every time. Another possiblility is to use one of the $sth->{NAME} attributes. E.g.:

$sth->execute(...); my $names = $sth->{NAME_lc}; while (my $row = $sth->fetch) { my %hash; $hash{@$names} = @$row; push @data, \%hash; }
I think Oracle does have some sort of LIMIT clause (update: oh yeah, see rownum below...), though its called something else I believe...check the Oracle docs...besides, selectall_arrayref and fetchall_arrayref have a $max_rows parameter...see those also.

Replies are listed 'Best First'.
Re: Re: selectrow_hashref upper/lower case
by valdez (Monsignor) on Oct 02, 2002 at 09:26 UTC

    That is what I was looking for! I read the DBI man, but didn't see that option... shame on me! Thank you very much runrig and panix!

    Ciao, Valerio