Use hub_table_SQL to obtain the table create statement and current data of a table (or tables) as a list of SQL statements. The command can optionally open a subscription to future changes. The data is read and the subscription is established without possible intervening change of the table data.
When a subscription is opened, the functionality is similar to opening a data subscription using the CREATE and SYNC options, but the efficiency can be greater since the create statement and current data is obtained as one large message instead of a flurry of small SQL messages. Also, the command integrates use of the hub_safe_sub_set command to provide safety checking for runaway subscriptions.
There is an option to obtain the SQL statements as a returned result, or to have it sent as the first message to a specified mailbox.
Command arguments:
"mbx whenmsg MYBOX_SQL mbx_SQL"Running the hub application script is also a means of setting up a mailbox to process received messages as SQL commands.
The command is part of the dmh package and resides in the ::dmh namespace. It can be imported to the global namespace using dmh_import.
# at the server process package require dmh # at the client process if { ![hub_table_exists dc_user] } { set tablelist {dc_user dc_user_group dc_user_privilege} set cmd [list eval ::dmh::hub_table_SQL $tablelist 1 0 $dc_ui(MB_SQL) $dc_ui(MB_SQL)] # this gives us the existing data as an efficient big reply # and opens subscriptions for future changes # and also registers us for safe subscription checking set reply [dc_ui_hub_xact $cmd $dc_ui(dmh)] foreach stmt $reply { SQL $stmt } mbx whenmsg $dc_ui(MB_SQL) mbx_SQL }