Re: plperl function

Поиск
Список
Период
Сортировка
От Emanuel Calvo Franco
Тема Re: plperl function
Дата
Msg-id f205bb120908131601k498c04e0o7d098569d08383bc@mail.gmail.com
обсуждение исходный текст
Ответ на plperl function  (Janet Jacobsen <jsjacobsen@lbl.gov>)
Список 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 по дате отправления:

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: comparing NEW and OLD (any good this way?)
Следующее
От: Greg Stark
Дата:
Сообщение: Re: max_allowed_packet equivalent in Postgres?