Search Postgresql Archives

plperl spi_prepare and arrays

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

 



Hi all,

Spent the last few hours searching but was unable to get a
satisfactory answer. Basically, if I do this:

my $arr = [1,2,3,4];
$_SHARED{test} = spi_prepare('update users set interest=$1 where
uid=2', 'int[]');
spi_exec_prepared($_SHARED{test}, $arr);

I get:

DBD::Pg::st execute failed: ERROR:  error from Perl function "view":
array value must start with "{" or dimension information

Okay, so I can pass the arrayref to spi_exec_prepared by making a
string out of it, with join() and string concatenation with curlies
and all that jazz, but this is an inefficient pain, especially if I
happened to have more than a 1D array. Shouldn't I be able to pass an
arrayref directly?

Also, what about going the other way - getting postgres arrays in
plperl as arrayrefs instead of as strings with curlies? In searching I
found this old message:

http://archives.postgresql.org/pgsql-general/2006-08/msg01472.php

... which suggests to me that it is indeed possible, but I would like
more details.

Thank you very much.


Nathan

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