Re: Help with a plperl function

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Alex <alex(at)meerkatsoft(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Help with a plperl function
Date: 2005-04-18 19:20:33
Message-ID: 20050418192033.GA48393@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Apr 19, 2005 at 03:00:07AM +1000, Alex wrote:
>
> i am having a problem with a plperl function. bellow function always
> returns me an error saying "elements of Perl result array must be
> reference to hash"
[snip]
> my $row = $rv->{rows}[$rn];
> my @record;
>
> $record[0] = $row->{item_id};
> $record[1] = $row->{item_descr};
> $record[2] = $row->{start_date};
>
> push @$res, @record;

You should be pushing a hash reference, not an array. Try something
like this:

my $row = $rv->{rows}[$rn];

push @$res, {item_id => $row->{item_id},
description => $row->{item_descr},
order_date => $row->{start_date}};

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message ElayaRaja S 2005-04-18 19:23:55 Uninstall existing - postgesql 7.3.2
Previous Message Leif B. Kristensen 2005-04-18 19:16:18 Pgsql config file