Connection/result handles as commands

PostgreSQL Tcl Interface Documentation
Prev | Fast Backward | Chapter 1. pgtcl - Tcl Binding Library | Fast Forward | Next

# 1.5. Connection/result handles as commands

Starting with version 1.5, you can use the connection/result handle as a Tcl command. What this means is that when a handle for a connection or result is generated, a corresponding Tcl command is also generate. For example, you can do the following:

    set conn [pg::connect template1 -host $host -port $port]
    set res [$conn exec "SELECT datname FROM pg_database ORDER BY datname;"]
    set datnames [$res -list]
    $res -clear
    rename $conn {} ;# or $conn disconnect

Note that deleting the command (`rename $conn {}`), has the same effect as `pg::result $res -clear` (if it is a result handle), and `pg::disconnect` (if it is a connection handle). Also, if that command gets overloaded with a proc definition, then that has the same effect as deleting the command.

Prev | Home | Next
Tcl Namespace Support | Up | Example Program