You could also use NVL (NAME, 'NONE') instead of the DECODE to achieve the
same result. However, the column alias is still required.
Steve
On Tuesday 02 July 2002 15:46, Stacy Mader wrote:
> Hello all,
>
> I ran into a little problem using fetchrow_hashref:
>
> use strict;
>
> $sth = $dbh->prepare(qq{ SELECT ID,
> DECODE(NAME,NULL,'NONE',NAME)
> FROM $table});
>
> $sth->execute();
> my(%hash) = %{$sth->fetchrow_hashref('NAME_lc')};
> $sth->finish;
>
> Now the keys for %hash are 'ID' and 'DECODE(NAME,NULL,'NONE',NAME)'. Not
> ideal on the latter. I worked around the problem with the following
> (Oracle) statement:
>
> $sth = $dbh->prepare(qq{ SELECT ID,
> DECODE(NAME,NULL,'NONE',NAME) AS NAME
> FROM $table});
>
>
> I thought it might be good to include this in the mail archives for
> reference.
>
> Regards,
>
> Stacy.