Pgtcl Reference Manual

The PostgreSQL Tcl Interface

Legal Notice

2014-09-12


Table of Contents

Preface
1. Overview
2. Building and Installing pgtcl-ng
2.1. Building and Installing on Unix-like Systems
2.1.1. Prerequisites for Unix-like Systems
2.1.2. Building and Installing - Unix-like Systems
2.2. Building and Installing on Windows (MinGW tools)
2.2.1. Prerequisites for Windows Systems (MinGW tools)
2.2.2. Building and Installing - Windows Systems (MinGW tools)
2.3. Building and Installing on Windows Systems (Borland Compiler)
2.3.1. Prerequisites for Windows Systems (Borland Compiler)
2.3.2. Building and Installing - Windows Systems (Borland Compiler)
2.4. Building and Installing on MacOS 10
2.4.1. Prerequisites for MacOS Systems
2.4.2. Building on MacOS
3. Loading pgtcl into an Application
3.1. Using the Tcl Package Command
3.1.1. "Package require" setup for Unix-like systems
3.1.2. "Package require" setup for Windows
3.2. Directly loading libpgtcl
3.3. Linking libpgtcl Into an Application
4. pgtcl Command Reference
4.1. Database Connection Control Commands
pg_connect — Open a connection to the server
pg_disconnect — Close a connection to the server
pg_conndefaults — Get connection options and their defaults
4.2. Connection Status Commands
pg_transaction_status — Get the current in-transaction status
pg_parameter_status — Get the value of a parameter from the database server
pg_backend_pid — Get the process ID (PID) of the backend
pg_server_version — Get the PostgreSQL server software version
4.3. Query Execution Commands
pg_exec — Execute an SQL command on the server
pg_execute — Execute an SQL command on the server and optionally loop over the results
pg_select — Execute an SQL command on the server and loop over the results
pg_exec_params — Execute a parameterized SQL command on the server
pg_exec_prepared — Execute a pre-prepared SQL command on the server
pg_describe_cursor — Get information about a cursor (portal)
pg_describe_prepared — Get information about a prepared statement
pg_result — Get information about a command result
pg_encrypt_password — Encrypt a password/username combination
pg_escape_string — Escape a string for use in an SQL string constant
pg_quote — Escape and quote a string for use as an SQL string literal
pg_escape_identifier — Escape a string for use as an SQL identifier (object name)
pg_escape_literal — Escape and quote a string for use as an SQL string literal
pg_escape_bytea — Escape a binary string for use in an SQL string constant with bytea (byte array) columns
pg_unescape_bytea — Unescape a string returned by an SQL query on a bytea (byte array) column, recovering the original binary string.
4.4. Asynchronous Query Processing Commands
pg_sendquery — Send an SQL command to the server for asynchronous execution
pg_sendquery_params — Send a parameterized SQL command to the server for asynchronous execution
pg_sendquery_prepared — Send a pre-prepared SQL command to the server for asynchronous execution
pg_isbusy — See if pg_getresult will block
pg_getresult — Wait for and return result from asynchronous SQL command
pg_cancelrequest — Cancel an in-progress asynchronous query
pg_blocking — Get or set the connection mode - blocking or nonblocking
pg_result_callback — Set a callback for asynchronous SQL command result availability
4.5. Notification and Notice Processing Commands
pg_listen — Set a callback for asynchronous notification messages
pg_on_connection_loss — Set a callback for unexpected connection loss
pg_notice_handler — Set a callback for notice or warning messages from the server
4.6. Large Object Processing Commands
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_lseek64 — Seek to a position of a large object, using a 64-bit offset
pg_lo_tell — Return the current seek position of a large object
pg_lo_tell64 — Return the current seek position of a large object, using 64-bit offsets
pg_lo_truncate — Truncate a large object, changing its size
pg_lo_truncate64 — Truncate a large object, changing its size, using a 64-bit offset
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
5. Example Programs
5.1. Example - Connect and query with pg_exec
5.2. Example - Connect and query with pg_execute
5.3. Example - Get List of Databases
5.4. Example - The Different Ways to Get Query Results
5.5. Example - Large Objects - Picture Viewer, Part 1 - Store Pictures
5.6. Example - Large Objects - Picture Viewer, Part 2 - View Pictures
5.7. Example - Prepared Queries - Picture Viewer, Part 1 - Store Pictures
5.8. Example - Prepared Queries - Picture Viewer, Part 2 - View Pictures
5.9. Example - Bytea Escaping - Picture Viewer, Part 1 - Store Pictures
5.10. Example - Bytea Escaping - Picture Viewer, Part 2 - View Pictures
5.11. Example - Asynchronous Queries
5.12. Example - Asynchronous Query with Event-Driven Results
5.13. Example - COPY FROM and COPY TO
SourceForge.net Logo

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.