pg_result -- get information about a command result
Synopsis
pg_result resultHandleresultOption
Description
pg_result returns information about a command result created by a prior pg_exec.
You can keep a command 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 have created too many command result objects.
Arguments
resultHandle
The handle of the command result.
resultOption
One of the following options, specifying which piece of result information to return:
-status
The status of the result.
-error
The error message, if the status indicates an error, otherwise an empty string.
-conn
The connection that produced the result.
-oid
If the command was an INSERT, the OID of the inserted row, otherwise 0.
-numTuples
The number of rows (tuples) returned by the query.
-cmdTuples
The number of rows (tuples) affected by the command.
-numAttrs
The number of columns (attributes) in each row.
-assign arrayName
Assign the results to an array, using subscripts of the form (rowNumber, columnName).
-assignbyidx arrayName ?appendstr?
Assign the results to an array using the values of the first column and the names of the remaining column as keys. If appendstr is given then it is appended to each key. In short, all but the first column of each row are stored into the array, using subscripts of the form (firstColumnValue, columnNameAppendStr).
-getTuple rowNumber
Returns the columns of the indicated row in a list. Row numbers start at zero.
-tupleArray rowNumberarrayName
Stores the columns of the row in array arrayName, indexed by column names. Row numbers start at zero.
-attributes
Returns a list of the names of the columns in the result.
-lAttributes
Returns a list of sublists, {name typeOid typeSize} for each column.
-clear
Clear the command result object.
Return Value
The result depends on the selected option, as described above.
Deliver First Class Web Sites: 101 Essential Checklists Want to learn how to make your web sites usable and accessible? Want to ensure that your sites meet current best practice, without spending hours trawling through incomprehensible specifications and recommendations from dozens of different books, research papers, and web sites? Want to make sure that the sites you build are "right the first time," requiring no costly redevelopments?