@@ -17,6 +17,7 @@ The pgtcl package provides the following commands.
1717pg_connect - opens a connection to the backend server
1818pg_disconnect - closes a connection
1919pg_exec - send a query to the backend
20+ pg_select- loop over the result of a select statement
2021pg_result - manipulate the results of a query
2122
2223pg_lo_creat- create a large object
@@ -54,7 +55,25 @@ The pgtcl package provides the following commands.
5455 the return result is either an error message or a handle for a query
5556 result. Handles start with the prefix "pgp"
5657
57- 4) pg_result:get information about a query result
58+ 4)pg_select:loop over the result of a select statement
59+
60+ syntax:
61+ pg_select connection query var proc
62+
63+ The query must be a select statement. Anything else returns an error.
64+ The var variable is an array name used in the loop. It is filled
65+ out with the result of the query for each tuple using the field
66+ names as the associative indeces. Proc is the procedure that is
67+ run for each tuple found.
68+
69+ example: (DB is set to database name)
70+ set conn [pg_connect $DB]
71+ pg_select $conn "SELECT * from table" array {
72+ puts [format "%5d %s" array(control) array(name)]
73+ }
74+ pg_disconnect $conn
75+
76+ 5) pg_result:get information about a query result
5877
5978 syntax:
6079 pg_result result ?option?