Data Replication provides commands in the ::dbs:: namespace that you can use to execute SQL commands for a target during Applier processing.
::dbs::create_stream -d <
SQL_statement
>
For Applier processing, creates the SQL stream object based on a SQL statement string that is written using the Oracle, ODBC and DB2-CLI Template Library, Version 4.0 (OTL 4.0) syntax. The command returns the integer ID of the SQL statement stream object for further use.
::dbs::delete_stream <
stream_ID
>
For Applier processing, deletes the SQL statement stream object that has the specified ID.
::dbs::bind_in <
stream ID
> <
string_object
>
For Applier processing, binds the string to the SQL statement stream placeholder. Call this function for each stream placeholder. For example, if SQL statement stream contains two placeholders, execute this command twice.
::dbs::bind_out <
stream_ID
>
For the SELECT statement stream, returns the current string object from the stream during Applier processing. The stream uses an iterator to iterate through the result string objects.
::dbs::flush <
option
>
For Applier processing, flushes SQL statement streams. You can use the following options:
-all. Flushes all opened streams of the Applier, except for streams opened by the user.
-s. Flushes all streams opened in the current thread, except for streams opened by the user.
::dbs::flush <
stream_ID
>
For Applier processing, flushes the SQL statement stream that has the specified ID if it was opened by the current user.
::dbs::check_eof <
stream_ID
>
For Applier processing, returns true if the end of the stream that has the specified ID has been reached. Otherwise, returns false.
::dbs::fetch_result <
stream_ID
>
For Applier processing, returns a Tcl list object, which represents the SQL statement result. Typically, the command returns a list of records that were selected by SELECT statement.
When InitialSync encounters any of these commands, it ends with an error. To exclude these commands from InitialSync processing, add a condition that checks the current operation type to determine if it is an InitialSync operation. For example, the following condition causes the Tcl script to flush SQL statement streams only when the operation type does not equal O (InitialSync Insert):
if {[::dbs::record::optype] != 'O'} {::dbs::flush -s}