PL/Perl: Is there a way to use spi_prepare/spi_exec_prepared with a list as second argument?
| От | Markus Wollny |
|---|---|
| Тема | PL/Perl: Is there a way to use spi_prepare/spi_exec_prepared with a list as second argument? |
| Дата | |
| Msg-id | 28011CD60FB1724DBA4442E38277F6260CA19336@hermes.computec.de обсуждение исходный текст |
| Список | pgsql-general |
Hello!
I'd like to dynamically prepare and execute a certain statement in
PL/perl, i.e. I don't know at the time of calling my trigger function
how many arguments I need to pass for this queries and which types they
have. The command string is assembled dynamically, as is the list of
type-identifiers and arguments.
So what i'd like to do is something like this:
my $_sQueryString = 'INSERT INTO foo VALUES ($1,$2,$3)';
my @_lColumnTypes = =('int4','int4','text');
my $_pColumnInsert = spi_prepare($_sQueryString, @_lColumnTypes);
... and a similar thing for the actual spi_exec_prepared().
So far my experiments were not successful, but that may be because I am
everything but a Perl monk :) The docs don't say anything about the
actual type of the second arguments, so I hoped that passing lists would
be somehow possible, thereby allowing for more dynamic declarations.
If this doesn't work, which would be the best way to proceed? I cannot
think of anything other than eval as a last resort.
Kind regards
Markus
Computec Media AG
Sitz der Gesellschaft und Registergericht: Furth (HRB 8818)
Vorstandsmitglieder: Albrecht Hengstenberg (Vorsitzender) und Rainer Rosenbusch
Vorsitzender des Aufsichtsrates: Jurg Marquard
Umsatzsteuer-Identifikationsnummer: DE 812 575 276
В списке pgsql-general по дате отправления: