This command is used to copy table data from a persistent database to an in-memory table. Optionally, a subset (selected columns/selected rows) of the data may be loaded. Optionally, the column names or tablename may be different. The column data types may be different but need to be compatible, such as DATE and VARCHAR. The in-memory table should already exist.
The command arguments are:
An error is returned if a table or the ODBC connection does not exist. The usual return value is a two element list consisting of the number of rows queried from the persistent database, and the number or rows successfully inserted into the in-memory table. The counts may be different if the in-memory table already has data with the same key values.
The command logic uses the odbc process_statement command to reduce the peak memory requirements needed to copy the table data.
The command is part of the Humelib package and it may be imported from the humelib namespace.
package require Humelib namespace import -force humelib::* odbc connect sql MYDB scott tiger # create in-memory table SQL "create table dc_custom (domain varchar(32), name varchar(32), \ description varchar(200), value varchar(2000), primary key(domain,name))" # load from persistent database set reply [SQL_tableload dc_custom] puts "rows processed, rows inserted=$reply"