SPI_prepare's parameter

Started by 高健over 13 years ago2 messagesgeneral
Jump to latest
#1高健
luckyjackgao@gmail.com

I am new to PostgreSQL's SPI(Server Programming Interface).

I can understand PostgreSQL's exampel of using SPI. But I am not sure about
SPI_prepare's parameter.

void * SPI_prepare(const char * command, int nargs, Oid * argtypes)

Can somebody kindly give an example of using SPI_prepare ?

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: 高健 (#1)
Re: SPI_prepare's parameter

高健 wrote:

I am new to PostgreSQL's SPI(Server Programming Interface).

I can understand PostgreSQL's exampel of using SPI. But I am not sure about SPI_prepare's parameter.

void * SPI_prepare(const char * command, int nargs, Oid * argtypes)

Can somebody kindly give an example of using SPI_prepare ?

Untested:

Oid types[] = { INT4OID };
SPIPlanPtr planptr = SPI_prepare("SELECT val FROM tab WHERE id = $1", 1, types);

Yours,
Laurenz Albe