Writer Directives
The directives processed by the ODBC 3.x Writer are listed below. The suffixes shown are prefixed by the current <WriterKeyword>
in a mapping file. By default, the <WriterKeyword>
for the ODBC 3.x writer is ODBC2
.
DATASET, USER_NAME, PASSWORD
The DATASET, USER_NAME, PASSWORD, directives operate in the same manner as they do for the ODBC 3.x reader. The remaining writer-specific directives are discussed in the following sections.
ABORT_ON_BAD_DATA
Required/Optional: Optional
Some features may contain out-of-range or invalid attribute values. These features will be rejected and cannot be written to the database. If the value of this directive is YES then the translation will be aborted immediately after encountering such a problem. If this directive is set to NO then the translation will continue but the features with rejected feature will not be written to the database.
Values: YES | NO
Default: NO
Example:
ODBC2_ABORT_ON_BAD_DATA YES
Workbench Parameter: Abort Translation On Bad Data
DEF
Required/Optional: Required
Each database table must be defined before it can be written. For the ODBC 3.x writer, the DEF line is specified in one of three forms. The first one is used for inserting data:
ODBC2_DEF <tableName> \ [odbc2_overwrite_table (YES|NO|TRUNCATE)] \ [<fieldName> <fieldType>] +
When the destination table does not exist, the table definition specifies the table that will be created. When the destination table exists and is not being dropped, the fields and types listed should match those of the existing table.
Fields in the table definition that do not match any existing columns will be ignored by the writer. Where <fieldType> is specified, it should be a field type supported by the target database.
If the table does not exist, or odbc2_overwrite_table is specified with a value of YES, then the field names and types are used to first create the table. In any case, if a <fieldType> is given, it may be any field type supported by the target database.
This example defines the SUPPLIER table for the FME. If the table did not exist, it will be created just before the first SUPPLIER row is written. If the table already exists, the data will be appended to the existing table.
ODBC2_DEF SUPPLIER \ ID integer \ NAME char(100) \ CITY char(50)
The following example is exactly the same, except that it replaces any existing table named SUPPLIER with a new table having the specified definition. If the table SUPPLIER does not exist in the database, then a new table is simply created.
ODBC2_DEF SUPPLIER \ odbc2_overwrite_table YES \ ID integer \ NAME char(100) \ CITY char(50)
The second form is used for updating data:
ODBC2_DEF <tableName> \ [odbc2_update_key_columns <columns>] \ [<fieldName> <fieldType>] +
The set of key columns to use (shown <columns> as above) is specified as a comma-separated list.
The third form is used for deleting data:
ODBC2_DEF <tableName> \ [odbc2_delete_key_columns <columns>] \ [<fieldName> <fieldType>] +
The set of key columns to use (shown <columns> as above) is specified as a comma-separated list.
PERSISTENT_CONNECTION
A user may want to keep a connection to a database for reuse during a particular FME session. For example, when running a batch of 100 mapping files on the same database connection, it may be desirable to keep a connection open and save the processing time required to make and break a database connection.
A database connection will be determined to be the same when the database name, the username, the password, and the transaction interval are the same.
Values: YES | NO
Default value: NO
Example:
ODBC2_PERSISTENT_CONNECTION YES
Workbench Parameter: Persistent Connection
TRANSACTION_INTERVAL
This statement informs FME about the number of features to be placed in each transaction before a transaction is committed to the database.
If the ODBC2_TRANSACTION_INTERVAL statement is not specified, then a value of 1000 is used as the transaction interval.
Parameter |
Contents |
<transaction_interval> |
The number of features in a single transaction. |
Default: 1000
Example:
ODBC2_TRANSACTION_INTERVAL 5000
Workbench Parameter: Transaction Interval