Unsupported versions: 6.3
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.
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