Chapter 29. pgtcl - Tcl Binding Library

Table of Contents
29.1. Overview
29.2. Loading pgtcl into an Application
29.3. pgtcl Command Reference
pg_connect -- open a connection to the server
pg_disconnect -- close a connection to the server
pg_conndefaults -- get connection options and their defaults
pg_exec -- send a command to the server
pg_result -- get information about a command result
pg_select -- loop over the result of a query
pg_execute -- send a query and optionally loop over the results
pg_listen -- set or change a callback for asynchronous notification messages
pg_on_connection_loss -- set or change a callback for unexpected connection loss
pg_lo_creat -- create a large object
pg_lo_open -- open a large object
pg_lo_close -- close a large object
pg_lo_read -- read from a large object
pg_lo_write -- write to a large object
pg_lo_lseek -- seek to a position of a large object
pg_lo_tell -- return the current seek position of a large object
pg_lo_unlink -- delete a large object
pg_lo_import -- import a large object from a file
pg_lo_export -- export a large object to a file
29.4. Example Program

pgtcl is a Tcl package for client programs to interface with PostgreSQL servers. It makes most of the functionality of libpq available to Tcl scripts.

29.1. Overview

Table 29-1 gives an overview over the commands available in pgtcl. These commands are described further on subsequent pages.

Table 29-1. pgtcl Commands

CommandDescription
pg_connectopen a connection to the server
pg_disconnectclose a connection to the server
pg_conndefaultsget connection options and their defaults
pg_execsend a command to the server
pg_resultget information about a command result
pg_selectloop over the result of a query
pg_executesend a query and optionally loop over the results
pg_listenset or change a callback for asynchronous notification messages
pg_on_connection_lossset or change a callback for unexpected connection loss
pg_lo_creatcreate a large object
pg_lo_openopen a large object
pg_lo_closeclose a large object
pg_lo_readread from a large object
pg_lo_writewrite to a large object
pg_lo_lseekseek to a position in a large object
pg_lo_tellreturn the current seek position of a large object
pg_lo_unlinkdelete a large object
pg_lo_importimport a large object from a file
pg_lo_exportexport a large object to a file

The pg_lo_* commands are interfaces to the large object features of PostgreSQL. The functions are designed to mimic the analogous file system functions in the standard Unix file system interface. The pg_lo_* commands should be used within a BEGIN/COMMIT transaction block because the descriptor returned by pg_lo_open is only valid for the current transaction. pg_lo_import and pg_lo_export must be used in a BEGIN/COMMIT transaction block.