select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Unsupported versions: 6.3
Historical version. PostgreSQL 6.3 reached end of support in March 2003. See the current manual for supported releases.
pg_select
PostgreSQL
Prev Next

pg_select

Name

pg_select — loop over the result of a select statement
pg_select dbHandle queryString
  arrayVar queryProcedure

Inputs

dbHandle

Specifies a valid database handle.

queryString

Specifies a valid SQL select query.

arrayVar

Array variable for tuples returned.

queryProcedure

Procedure run on each tuple found.

Outputs

queryHandle

the return result is either an error message or a handle for a query result.

Description

pg_select submits a query to the Postgres backend. and returns the results. The queryString must be a select statement. Anything else returns an error. The arrayVar variable is an array name used in the loop. It is filled out with the result of the query for each tuple using the field names as the associative indices.

Usage

       set DB "mydb"
        set conn [pg_connect $DB]
        pg_select $conn "SELECT * from table" array {
                puts [format "%5d %s" array(control) array(name)]
        }
        pg_disconnect $conn

Prev Home Next
pg_exec Up pg_result

Report a documentation issue

Read the upstream documentation. For corrections, first check the current manual.