@@ -17,6 +17,7 @@ The pgtcl package provides the following commands.
17
17
pg_connect - opens a connection to the backend server
18
18
pg_disconnect - closes a connection
19
19
pg_exec - send a query to the backend
20
+ pg_select - loop over the result of a select statement
20
21
pg_result - manipulate the results of a query
21
22
22
23
pg_lo_creat - create a large object
@@ -54,7 +55,25 @@ The pgtcl package provides the following commands.
54
55
the return result is either an error message or a handle for a query
55
56
result. Handles start with the prefix "pgp"
56
57
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
58
77
59
78
syntax:
60
79
pg_result result ?option?
0 commit comments