Search Postgresql Archives

Re: plperl function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>
>    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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux