PostgreSQL Tcl Interface Documentation
Prev | Fast Backward |  | Fast Forward | Next

# pg_sendquery

## Name

pg_sendquery -- send a query string to the backend connection without waiting for a result

## Synopsis

    pg_sendquery [-paramarray [-variables] arrayVar] conn commandString ?args?

## Description

`pg_sendquery` submits a command to the PostgreSQL server. This function works like `pg_exec`, except that it does not return a result. Rather, the command is issued to the backend asynchronously.

The result is either an error message or nothing. An empty return indicates that the command was dispatched to the backend.

If the [-paramarray] flag is provided, then a substitution is performed on the query, securely replacing each back-quote delimited name with the corresponding entry from the named array. If the array does not contain the named element, then NULL is substituted (similarly to the way an array created by -withoutnulls is generated). Each such name must occur in a location where a value or field name could appear. See pg_select for more info.

If the [-variables] flag is provided, then embedded Tcl variables are passed as parameters. Variables can be flagged with ':' and array references and namespaces are supported. Complex variable names can usually be embedded with :{nasty-name-here} though no attempt at duplicating Tcl brace-escaping is made. If the variable does not exist, then NULL is substituted. Each such name must occur in a location where a value or field name could appear. See pg_select for more info.

## Arguments

[-paramarray arrayname]

  Perform parameter substitution via `quoted` elements of the array using PQexecParams or PQSendQueryParams.

[-variables]

  Substitute Tcl variables found in the SQL string using PQexecParams or PQSendQueryParams.

`conn`

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

`commandString`

  The SQL command to execute.

`args`

  For PostgreSQL versions greater than 7.4, `args` consists of zero or more optional values that can be inserted, unquoted, into the SQL statement using $-style substitution. Nulls are represented by the string "NULL".

## Return Value

A Tcl error will be returned if pgtcl was unable to issue the command. Otherwise, an empty string will be return. It is up to the developer to use `pg_getresult` to obtain results from commands issued with `pg_sendquery`.

Prev | Home | Next
pg_on_connection_loss | Up | pg_sendquery_prepared