This page in other versions: Unsupported versions: 6.3
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

Submit correction

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.

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