Table of Contents

Search

  1. Preface
  2. Scripting Overview
  3. Tcl Scripting
  4. SQL Scripting

Adding Tcl Packages and Third-Party Extensions to a Script

Adding Tcl Packages and Third-Party Extensions to a Script

The TCL Script Engine is based on Tcl/Tk 8.5.9 distribution, which comes with the TCLLIB standard library. You can use all packages that the Data Replication distribution provides, without restriction.
To attach packages to a script, use the package require command. Informatica recommends adding packages to a script for the initialization or finalization processing stages.
The following example attaches matrix and csv packages, creates the matrix object, extracts cvs data from the file to the matrix object, and extracts the appropriate cell from the matrix object:
# dbs_worker_start.tcl – starting script file package require Tcl 8.2 package require struct::matrix package require Tcl 8.3 package require csv package require Tcl 8.2 set file [open ./hash.csv r] ::struct::matrix csv_matrix ::csv::read2matrix $file csv_matrix "," auto set des_maker \ [ csv_matrix get cell 0 \ [ lindex [ lindex [ csv_matrix search all "des_maker" ] 0 ] 1 ] ]
Also, you can use third-party Tcl extensions such as Oratcl or the SQLite TCL interface. To install an extension, see the third-party documentation. Use
./support/tcl/
as TCLROOT directory. The following example adds the Oratcl package to a finalization script:
package require Oratcl package require -exact Oratcl 4.5 set lh [ oralogon some_login/some_pass@//some_host:1521/orcl ] puts [orainfo version] puts [ orainfo server $lh ] set sh [ oraopen $lh ] set dic [ ::dbs::getglob hash1 ] dict for { key value } $dic { set sql { insert into DUMP (COLUMN1,COLUMN2) values ( :key , value ) } oraparse $sh $sql orabind $sh :key $key :value $value oraexec $sh } oracommit $lh oraclose $sh oralogoff $lh

0 COMMENTS

We’d like to hear from you!