In SQL, you can use the CREATE TABLE AS SELECT statement to copy the contents of an existing table or tables into a new table. The CTAS statement creates a new table based on the output of a SELECT statement. The Simba SQLEngine allows you to support CTAS commands in your custom ODBC driver.
Example CTAS statement:
The following statement copies the table Employee to the table NewTable:
CREATE TABLE NewTable AS SELECT * FROM Employee
The command CREATE TABLE AS SELECT is also called CREATE TABLE AS.
The SimbaEngine X SDK supports the SQL 2003 specification for CREATE TABLE AS, with the following exceptions:
To implement CTAS in your driver, your driver must have read-write capability. As well, your driver must implement the
MyDataEngine::CreateTable() method, where
MyDataEngine is your
When a CTAS SQL command is received, the SimbaEngine X SDK calls your driver's
MyDataEngine::BeginCreateTable(). Then, the SimbaEngine X SDK passes in a table specification. The
BeginCreateTable() method must return an object of a class that implements
ITableTemplate. The SimbaEngine X SDK fills in the table template, then calls
Instantiate() on the template. Your driver must provide the implementation of
Example - Implementing CTAS in Your Driver
MyTableclass to extend
ITableTemplatein addition to any other classes that it extends.
MyTable::Instantiate()method. This method should ensure that the table is ready to be used.
MyDataEngineclass to implement the