Re: plperl function

From: Emanuel Calvo Franco <postgres(dot)arg(at)gmail(dot)com>
To: Janet Jacobsen <jsjacobsen(at)lbl(dot)gov>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plperl function
Date: 2009-08-13 23:01:25
Message-ID: f205bb120908131601k498c04e0o7d098569d08383bc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
>    ERROR:  operator does not exist: integer = integer[]
>    HINT:  No operator matches the given name and argument type(s).
>    You might need to add explicit type casts.
>

Sounds like you are trying to return directly the query.

You must do a loop with that query inside (cursor) and
use next clause (to return one by one the values)
OR
return the query directly using return query (i don't remember
right now the plperl function to do that)

CREATE OR REPLACE FUNCTION perl_func()
RETURNS SETOF INTEGER AS $$
my $rv = spi_exec_query('select id from ctable where cmid in (
select i from mlist( 168.4, 55.2, 0.1 ) );');
my $status = $rv->{status};
my $nrows = $rv->{processed};
foreach my $rn (0..$nrows -1) {
return_next($row->{i});
}
return undef;
$$ LANGUAGE plperl;

SELECT * FROM perl_func();

I didn't test it, if you have problems, i'll try to help again :)

The error is telling you that could not return an array into
integer.

--
Emanuel Calvo Franco
Database consultant at:
www.siu.edu.ar
www.emanuelcalvofranco.com.ar

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2009-08-13 23:03:37 Re: max_allowed_packet equivalent in Postgres?
Previous Message Greg Stark 2009-08-13 22:53:49 Re: comparing NEW and OLD (any good this way?)