From: | "Markus Wollny" <Markus(dot)Wollny(at)computec(dot)de> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | PL/Perl: Is there a way to use spi_prepare/spi_exec_prepared with a list as second argument? |
Date: | 2009-05-05 15:38:35 |
Message-ID: | 28011CD60FB1724DBA4442E38277F6260CA19336@hermes.computec.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Spotts | 2009-05-05 16:55:52 | Re: Converting Rows to Columns |
Previous Message | Andreas Kretschmer | 2009-05-05 15:11:23 | Re: Converting Rows to Columns |