This example is the same as the previous example, except
it uses pg_execute instead of pg_exec to
query the database. pg_execute
is simpler to use
in some circumstances, but less flexible since it does not return
a result handle.
In this example, we use the fact that pg_execute
will
store the query values as variables named by the result column names
(if not given the -array name
option), and if the query
returns a single row there is no need for a procedure body.
Example 5.2. Connect to the database and get its version with pg_execute
set conn [pg_connect -conninfo "host=server.example.com dbname=template1 user=guest password=secret"] pg_execute $conn "SELECT version() AS v" puts "Server version is: $v" pg_disconnect $conn
This version of the manual was produced for the
Pgtcl-ng Sourceforge project web service site, which requires the logo on each
page.
To download a logo-free copy of the manual, see the
Pgtcl-ng project
downloads area.