How to pass multiple arguments in spi_prepare?

Поиск
Список
Период
Сортировка
Искать

How to pass multiple arguments in spi_prepare?

От:
paresh masani <masaniparesh@gmail.com>
Дата:
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
FAQ