CREATE_TABLE_FROM_DAT_FILE¶

Applies to: ORAFlex SQLFlex MYSQLFlex PGFlex DB2Flex

This command is used to create a SQL table from a .DAT file. The table being copied must be not be opened in order for this command to work properly. This is the programmatic equivalent to using the Flex2SQL Migration Tool when Create Table and Index is selected. Optional restructuring options can be specified here (see below) as well as an alternative table name than the physical name of the .DAT file. Note that this only creates the table structure, no data will be copied here. To copy the data, use COPY_DATA after the table has been created.

The possible options are:

  • DF_STRUCTEND_OPT_FORCE_INVK - Deprecated - forces inverse keys to be created.

  • DF_STRUCTEND_OPT_OLD_INVK_NAME - Deprecated -

  • DF_STRUCTEND_OPT_FORCE_NOT_NULL - forces all fields to be created as NOT NULL.

  • DF_STRUCTEND_OPT_CREATE_ROWID_TABLE - A rowId table does not use RECNUM to uniquely identify a record, but instead relies on you specifying one or more fields that when combined create a unique record identity.

Note

This command can also be called within a ENABLE_SCRIPTING/DISABLE_SCRIPTING block. The script can then be retrieved using GET_SQL_SCRIPT_CHUNK. In this case, no table will be created on the back end.

Syntax

CREATE_TABLE_FROM_DAT_FILE {FileNumber} [{options} {table}]

Parameter

Description

FileNumber

Number of the file

options

DF_STRUCTEND_OPT_FORCE_INVK DF_STRUCTEND_OPT_OLD_INVK_NAME DF_STRUCTEND_OPT_CREATE_ROWID_TABLE DF_STRUCTEND_OPT_FORCE_NOT_NULL (optional)

table

name of table to use instead of physical name (optional)

Example

Login "localhost" "user" "pass123" "sql_drv"
open Customer
CREATE_TABLE_FROM_DAT_FILE Customer.File_Number "Customer"
COPY_DATA "Customer" to "sql_drv:Customer" CALLBACK (Callback(Self)) CONSTRAIN "STATUS = 'Active'"
close Customer

Example with single option
Login "localhost" "user" "pass123" "sql_drv"
open Customer
CREATE_TABLE_FROM_DAT_FILE Customer.File_Number DF_STRUCTEND_OPT_FORCE_NOT_NULL "Customer"
COPY_DATA "Customer" to "sql_drv:Customer" CALLBACK (Callback(Self)) CONSTRAIN "STATUS = 'Active'"
close Customer

Example with multiple options

Login "localhost" "user" "pass123" "sql_drv"
open Customer
CREATE_TABLE_FROM_DAT_FILE Customer.File_Number (DF_STRUCTEND_OPT_CREATE_ROWID_TABLE+DF_STRUCTEND_OPT_FORCE_NOT_NULL) "Customer"
COPY_DATA "Customer" to "sql_drv:Customer" CALLBACK (Callback(Self)) CONSTRAIN "STATUS = 'Active'"
close Customer