Accessing databases
PL/Tcl functions provide you with SPI functions to access the database and run DML/DDL statements.
The functions are the following:
spi_exec
: This executes a SQL statementspi_prepare
: This prepares a SQL statementspi_execp
: This executes a prepared statement
The spi_exec
function has the following syntax:
spi_exec ?-count n? ?-array name? command ?loop-body?
The spi_exec
function runs a SQL statement, and it takes some optional parameters, as follows:
-count
: This parameter allows you to specify the maximum number of rows processed by the command. If you provide the value 3, only 3 rows will be processed. This is similar to specifyingFETCH [n]
in a cursor.-array
: If this parameter is specified, the column values are stored into ...
Get PostgreSQL Server Programming - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.