Version 9 of Oratcl

Updated 2002-11-14 19:21:24

Purpose: Discuss the Tcl <-> Oracle DBMS binding

http://oratcl.sf.net/ is the home page for this package binding Oracle to Tcl.

Insert your favorite Oratcl tips, tricks, and hints, etc. here. Also, point to various useful reading, such as BOOK Tcl/Tk Tools, or BOOK Oracle and Open Source.

"Cinderella languages" [L1 ] is a published article on Oratcl's origins.

Tom Poindexter created Oratcl. Todd M. Helfter currently maintains it. Tom Poindexter's Oratcl page http://www.nyx.net/~tpoindex/tcl.html has a little bit about Oratcl, but the primary work on the extension is being done by Todd via the SourceForge project.


Todd points out that, "OraTcl relies on the Oracle install. This means different things on different platforms.

On Unix, the ORACLE_HOME environment variable must point to a valid Oracle install.

On windows, the ociw32.lib file must be found in the WINDOWS search path. In the past, I have had to place the oracle directory in the windows PATH variable in autoexec.bat. In later releases, the registry information was sufficient to find the file."


Tcl has other connections to COMPANY: Oracle.


tksql is an application for editing PostgreSQL (not Oracle) tables.


A recent article on comp.lang.tcl by Kevin Rodgers asked for comments about this sample boilerplate:

 # For error reporting:
 set program [file tail $argv0]

 # Package interface:
 package require Oratcl

 # Connect to the $env(TWO_TASK) database as USER with PASSWORD:
 if [catch {oralogon "USER/PASSWORD"} ora_logon] {
    puts stderr "$program: $ora_logon"
    exit 1
 }
 if [catch {oraopen $ora_logon} ora_statement] {
    oralogoff $ora_logon
    puts stderr "$program: $ora_statement"
    exit 1
 }
 #if [catch {oraconfig $ora_statement fetchrows 1024} ora_error] {
 #    puts stderr "$program: $ora_error"
 #} 

 # Execute SQL statement:
 set sql "SELECT column_1, ... column_N FROM ... WHERE ..."
 if [catch {orasql $ora_statement $sql} ora_error] {
    puts stderr "$program: $ora_error"
 } elseif {$oramsg(rc) != 0} {
    puts stderr "$program: $oramsg(errortxt)"
 } else {
    # Process each row with column_I bound to var_I:
    while {$oramsg(rc) == 0} {
        if [catch {orafetch $ora_statement \
                            {... $var_1 ... $var_N ...} \
                            '@' var_1 1 ... var_N N} \
                  ora_error] {
            puts stderr "$program: $ora_error"
            break
        } elseif {$oramsg(rc) == 1403} {
            break
        } elseif {$oramsg(rc) != 0} {
            puts stderr "$program: $oramsg(errortxt)"
            break
        }
    }
 }

 # Disconnect from the $env(TWO_TASK) database:
 if [catch {oraclose $ora_statement ora_error] {
    puts stderr "$program: $ora_error"
 }
 if [catch {oralogoff $ora_logon ora_error] {
    puts stderr "$program: $ora_error"
 }

Category Package Category Database