Re: Perl error: fetchrow_hashref failed

Поиск
Список
Период
Сортировка
От Moray McConnachie
Тема Re: Perl error: fetchrow_hashref failed
Дата
Msg-id 013101bfa474$a2d03960$760e01a3@oucs.ox.ac.uk
обсуждение исходный текст
Ответ на Perl error: fetchrow_hashref failed  (Jeffrey <seesej@uswest.net>)
Ответы Re: Perl error: fetchrow_hashref failed  (Jeffrey <seesej@uswest.net>)
Список pgsql-general
----- Original Message -----
From: "Jeffrey" <seesej@uswest.net>
To: <pgsql-general@postgresql.org>
Sent: Wednesday, April 12, 2000 10:05 AM
Subject: [GENERAL] Perl error: fetchrow_hashref failed


> Hi, I wonder if I might tap the vast knowledge here againg.
>
> I have a perl script that is looping through a statement handle like this.
>
> $statement = "select * from sometable";
> $sth=$dbh->prepare($statement);
> $sth->execute();
>
> # here is the part I have a question about.
> while (%hash_ref = %{$sth->fetchrow_hashref}) {
>
>     while (($k,$v) = each (%hash_ref)) {
>         print ("\n$k == $v"); }
> }

I don't think your first loop will work because the %{$b} where $b is undef
will not produce an undef - I think.

See if this works? It ought to be more efficient anyway, because you only
need one hash in my version, not two like your routine (that created by the
fetchrow_hashref call and the hash %hashref itself.

while (defined $hash_ref=$sth->fetchrow_hashref) {
    while (($k,$v)=each %$hashref) {
        print ("\n$k==$v");
    }
}




В списке pgsql-general по дате отправления:

Предыдущее
От: "Oliver Elphick"
Дата:
Сообщение: PostgreSQL (fwd)
Следующее
От: wieck@debis.com (Jan Wieck)
Дата:
Сообщение: Re: foriegn key...