Re: plperl function - Mailing list pgsql-general

From Emanuel Calvo Franco
Subject Re: plperl function
Date
Msg-id f205bb120908131601k498c04e0o7d098569d08383bc@mail.gmail.com
Whole thread Raw
In response to plperl function  (Janet Jacobsen <jsjacobsen@lbl.gov>)
List 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

pgsql-general by date:

Previous
From: Greg Stark
Date:
Subject: Re: comparing NEW and OLD (any good this way?)
Next
From: Greg Stark
Date:
Subject: Re: max_allowed_packet equivalent in Postgres?