pg_exec

Name

pg_exec -- send a command to the server

Synopsis

pg_exec conn commandString

Description

pg_exec submits a command to the PostgreSQL server and returns a result. Command result handles start with the connection handle and add a period and a result number.

Arguments

conn

The handle of the connection on which to execute the command.

commandString

The SQL command to execute.

Return Value

Returns a result handle which can be used with pg_result to obtain the results of the command.

A Tcl error will be thown if an error occurs communicating with the database. Note that no Tcl error will be thrown if an invalid query is successfully sent to the server and a response successfully received. The result status must be checked after a normal return.

Notes

Be sure to free the result handle with pg_result -clear when you are done with it.

pg_exec can be used to start a COPY, after which the application reads directly from or writes directly to the connection handle. See Section 5.10 for an example.