pg_sendquery — Send an SQL command to the server for asynchronous execution
pg_sendqueryconn
commandString
?param...
?
pg_sendquery
sends a command to the PostgreSQL server and
returns immediately, without waiting for the command to complete and
without providing a result handle.
Optional arguments can be supplied to replace parameter place-holders in the
command string.
conn
The handle of the connection on which to execute the command.
commandString
The SQL command to execute.
param...
Zero or more parameter values to bind to command string
place-holders.
The first argument will replace $1
in the
command string, the second argument will replace
$2
, etc.
Use pg_isbusy to see if the command is still being executed. Use pg_getresult to get the result, waiting for the command to complete if necessary. Alternatively, use pg_result_callback to register a callback command to be executed when a result is ready (that is, when pg_getresult will not block).
If optional arguments are supplied, this command becomes a simplified form
of pg_sendquery_params, supporting only text-format
arguments with a text-format result. The command string must include parameter
place-holders $1
, $2
, etc. and an equal
number of parameter arguments.
Be sure to brace-quote or escape the parameter place-holders such as
$1
in the SQL command string to protect them from Tcl
variable expansion.
Use of these parameters avoids the need to quote and escape values which would
otherwise have to be substituted directly into the command string.
The form of this command using optional arguments for parameterized queries was added in pgtclng-1.6.0.
This command uses or emulates the PostgreSQL libpq
function PQsendQuery
if called without optional
query parameter arguments, and the
function PQsendQueryParams
if called with optional
query parameter arguments.
This version of the manual was produced for the
Pgtcl-ng Sourceforge project web service site, which requires the logo on each
page.
To download a logo-free copy of the manual, see the
Pgtcl-ng project
downloads area.