This page in other versions: Unsupported versions: 7.1 / 7.2 / 7.3 / 7.4



pg_result -- get information about a query result


pg_result resultHandle resultOption



The handle for a query result.


Specifies one of several possible options.



the status of the result.


the error message, if the status indicates error; otherwise an empty string.


the connection that produced the result.


if the command was an INSERT, the OID of the inserted tuple; otherwise 0.


the number of tuples returned by the query.


the number of attributes in each tuple.

-assign arrayName

assign the results to an array, using subscripts of the form (tupno,attributeName).

-assignbyidx arrayName ?appendstr?

assign the results to an array using the first attribute's value and the remaining attributes' names as keys. If appendstr is given then it is appended to each key. In short, all but the first field of each tuple are stored into the array, using subscripts of the form (firstFieldValue,fieldNameAppendStr).

-getTuple tupleNumber

returns the fields of the indicated tuple in a list. Tuple numbers start at zero.

-tupleArray tupleNumber arrayName

stores the fields of the tuple in array arrayName, indexed by field names. Tuple numbers start at zero.


returns a list of the names of the tuple attributes.


returns a list of sublists, {name ftype fsize} for each tuple attribute.


clear the result query object.


The result depends on the selected option, as described above.


pg_result returns information about a query result created by a prior pg_exec.

You can keep a query result around for as long as you need it, but when you are done with it, be sure to free it by executing pg_result -clear. Otherwise, you have a memory leak, and Pgtcl will eventually start complaining that you've created too many query result objects.

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group