How to pass multiple arguments in spi_prepare?

From: paresh masani <masaniparesh(at)gmail(dot)com>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: How to pass multiple arguments in spi_prepare?
Date: 2009-10-05 13:17:33
Message-ID: a9d94e070910050617p40e93c06o95dacb0b2dc7077b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

Could anyone please help with my simple question? I understood below
spi_prepare and spi_exec_prepared example given in PostgreSQL
documentation.

CREATE OR REPLACE FUNCTION init() RETURNS INTEGER AS $$
$_SHARED{my_plan} = spi_prepare( ’SELECT (now() + $1)::date AS now’,
’INTERVAL’);
$$ LANGUAGE plperl;

CREATE OR REPLACE FUNCTION add_time( INTERVAL ) RETURNS TEXT AS $$
return spi_exec_prepared(
$_SHARED{my_plan},
$_[0],
)->{rows}->[0]->{now};
$$ LANGUAGE plperl;

CREATE OR REPLACE FUNCTION done() RETURNS INTEGER AS $$
spi_freeplan( $_SHARED{my_plan});
undef $_SHARED{my_plan};
$$ LANGUAGE plperl;

Could you tell me what could what could be the spi_prepare command and
argument for below query?

INSERT INTO myschema.mytable ("col1", "col2") VALUES (100,200);

Thanks,
Paresh

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Holderness 2009-10-05 13:46:19 psql in bash - how to clear screen?
Previous Message Thomas Kellerer 2009-10-04 20:40:23 Re: Installation on Windows 2003 fails