## Code Specification

In the code specification, you can define the default code type for interpreting data streams that contain plain text values. You can determine code specifications for a Loader session or for a Loader command by using the SET command to define the data format.

### Syntax

<set_codetype_command> ::= SET CODETYPE <standard_code_spec>

<code_spec> ::= <standard_code_spec>
| CODESET <literal>

<standard_code_spec> ::= ASCII | UCS2 | UTF8

ASCII | The code type for interpreting data streams is ASCII The Loader’s default value is ASCII
UCS2 | The code type for interpreting data streams is UCS2
UTF8 | The code type for interpreting data streams is UTF8
CODESET <literal> | literal: name of the code type See the SQL Reference Manual, Literal (literal)

Code specification when using LONG data:

<lob_code_spec> ::= <code_spec> | BINARY

BINARY | Data is exported/imported without being converted Specifying BINARY is only useful for columns of the data type LONG BYTE.

### Examples

EXPORT TABLE hotel.room
CATALOG OUTSTREAM 'room_ddl.catalog'
DATA OUTSTREAM 'room_csv.data' ASCII

Specifying the code when LONG data is used:
Exporting and Importing LONG values

### Explanation

If the code_spec code specification is missing in the command, the Loader uses the code type set by the SET CODETYPE command or a default value.

● SET CODETYPE command:
This setting applies to the entire Loader session provided that the character strings are not changed by another SET CODETYPE command.
You can change the current value for individual commands by using the syntax element code_spec to define the data format (field_format_spec).

● Default value: this is derived from the internal database data type of the column to be imported. If the internal database data type and the code specified for the data streams are different, the Loader converts the data. If the data base type and the code specification are incompatible, the Loader generates an error message and stops processing the command.

#### <code_spec>

When you export or import data, you can transform it between various code types. If you export/import ASCII data into an ASCII database or UCS2 data into a UNICODE database, the data does not have to be converted.

The following combinations are possible (internal and external database data types):

Internal Database Data Type | Possible Code Specifications for Data Streams with Clear Text Values when Exporting Data
(VAR)CHAR ASCII | ASCII, UCS2, UTF8
(VAR)CHAR UNICODE | UCS2, UTF8
(VAR)CHAR BYTE | BINARY, ASCII (HEX), UCS2 (HEX), UTF8 (HEX)
Numeric data types | ASCII, UCS2, UTF8

Internal Database Data Type | Possible Code Specifications for Data Streams with Clear Text Values when Importing Data
(VAR)CHAR ASCII | ASCII
(VAR)CHAR UNICODE | ASCII, UCS2, UTF8
(VAR)CHAR BYTE | BINARY, ASCII, UCS2 (HEX), UTF8 (HEX)
Numeric data types | ASCII, UCS2, UTF8

#### <lob_code_spec>

When you export /import LONG data, you determine the default code types by using the syntax rule lob_code_spec. This enables you to convert LONG data between various code types.

If you are exporting/importing ASCII LONG data into an ASCII database or UCS2 LONG data into a UNICODE database, the data does not have to be converted.

The following combinations are possible (internal and external database data types):

Internal Database Data Type | Possible Code Specifications of the LONG Data Stream for Exporting Data
LONG ASCII | ASCII, UCS2, UTF8
LONG UNICODE | UCS2, UTF8
LONG BYTE | BINARY, ASCII (HEX), UCS2 (HEX), UTF8 (HEX)

Internal Database Data Type | Possible Code Specifications of the LONG Data Stream for Importing Data
LONG ASCII | ASCII
LONG UNICODE | ASCII, UCS2, UTF8
LONG BYTE | BINARY, ASCII, UCS2 (HEX), UTF8 (HEX)

See also:

Importing and Exporting LONG Values

Data Types

SQL Reference Manual, Data Type (data_type)