pg_result
returns information about a command result
created by a prior pg_exec, pg_exec_prepared,
or pg_getresult.
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.
The handle of the command result.
One of the following options, specifying which piece of result information to return:
Assign the results to an array, using subscripts of the form (rowNumber,columnName).
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).
Returns a list of the names of the columns in the result.
Clear the command result object.
Returns the number of rows (tuples) affected by the command. This is appropriate to use for commands with completion status PGRES_COMMAND_OK.
Returns the handle (name) of the connection that produced the result.
Returns the error message, if the status indicates an error, otherwise an empty string.
Returns the value of an extended error code field. fieldCode selects the error code field by full name or single character abbreviation, according to the following table.
FieldCode | Abbreviated FieldCode | Description |
---|---|---|
SEVERITY | S | ERROR or FATAL, for example |
SQLSTATE | C | 5-character SQL State |
MESSAGE_PRIMARY | M | Primary error message |
MESSAGE_DETAIL | D | Optional detailed message |
MESSAGE_HINT | H | Optional suggestion |
STATEMENT_POSITION | P | Decimal integer cursor position |
CONTEXT | W | Call Stack trace |
SOURCE_FILE | F | PostgreSQL source code filename |
SOURCE_LINE | L | PostgreSQL source code line number |
SOURCE_FUNCTION | R | PostgreSQL source code function name |
Returns a list of 1s and 0s for the indicated row, with 1 meaning the value of the column is NULL, and 0 meaning the value of the column is not NULL. Row numbers start at zero.
Returns the values of the columns of the indicated row in a list. Row numbers start at zero.
Returns a list of attributes of the query result columns. For each column, the list contains a sublist of the form {ColumnName TypeOid TypeSize}. More information on these values can be found in the PostgreSQL Libpq documentation. Note that pg_result -lxAttributes returns a superset of this information.
Returns the entire result as a list of values in row-major, column-minor order.
Returns the entire result as a list of lists. The outer list contains one element for each result row, and the inner lists contain the values for each column of the row.
Returns an extended list of attributes of the query result columns. For each column, the list contains a sublist of the form {ColumnName TypeOid TypeSize TypeSizeModifier Format TableOID TableColumnIndex}. More information on these values can be found in the PostgreSQL Libpq documentation. Note that this is an extension of the information returned by pg_result -lAttributes.
Returns the number of columns (attributes) in each row.
Returns the number of rows (tuples) returned by the query. This is appropriate to use for commands with completion status PGRES_TUPLES_OK.
If the command was a single row INSERT, returns the OID (Object ID) of the inserted row, otherwise returns 0.
Returns the status of the result. This will be one of the following strings:
Status | Meaning |
---|---|
PGRES_COMMAND_OK | Successful completion of a command returning no data, such as INSERT. |
PGRES_TUPLES_OK | Successful completion of a command which returns data (such as SELECT or SHOW). Note this is the status even if the SELECT happens to return no rows. |
PGRES_COPY_OUT | Begin COPY TO STDOUT. |
PGRES_COPY_IN | Begin COPY FROM STDIN. |
PGRES_EMPTY_QUERY | The query string sent to the server was empty. |
PGRES_BAD_RESPONSE | The server's response was not understood. |
PGRES_FATAL_ERROR | An error occurred. This includes any SQL syntax errors, or errors processing the command such as SELECT from a non-existing table. |
Stores the columns of the row in array arrayName, indexed by column names. Row numbers start at zero.