Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group