4. Manage CFI Loader Columns¶
Before adding column definitions to a CFI loader make sure that the loader exists and all BDomain metadata have been set.
[Add CFI BDomain Settings](#cfi-add-bdomain-settings
4.1. Add a CFI Loader Column¶
For each column of the source file a specification for the target TSA-table must be added using API_CFIADM.ADD_LOADER_BD_COLUMN. Mind that not only the name and data type are important parameteres but also the position of the column in the file.
For VARCHAR columns the size must be provided. The rest of the parameters can be set to NULL for INT and VARCHAR columns.
The variable p_col_scale can be used to define the number of decimal positions that should be used for columns of the type DECIMAL. For this column type the column size also has to be set and the format of the column has to be defined (see Exasol Documentation). The rest of the variables can be set to null for this column type as well.
For columns of the type DATE only the column format has to be defined additionally to the variables having to be provided for all other column types as well.
The examples below show a definition for each column type.
Example - column type = ‘int’
1EXECUTE SCRIPT API_CFIADM.ADD_LOADER_BD_COLUMN(
2 'PERSON' -- p_ldr_name
3 ,'TESTING' -- p_bdomain
4 ,'id' -- p_col_name
5 ,'int' -- p_col_data_type
6 ,null -- p_col_size
7 ,null -- p_col_scale
8 ,null -- p_col_format
9 ,1 -- p_col_pos
10 ,null -- p_col_fbv_size
11 ,null -- p_col_fbv_start
12 ,null -- p_col_fbv_align
13 ,null -- p_col_fbv_padding
14);
Example - column type = ‘varchar’
1EXECUTE SCRIPT API_CFIADM.ADD_LOADER_BD_COLUMN(
2 'PERSON' -- p_ldr_name
3 ,'TESTING' -- p_bdomain
4 ,'FirstName' -- p_col_name
5 ,'varchar' -- p_col_data_type
6 ,100 -- p_col_size
7 ,null -- p_col_scale
8 ,null -- p_col_format
9 ,2 -- p_col_pos
10 ,null -- p_col_fbv_size
11 ,null -- p_col_fbv_start
12 ,null -- p_col_fbv_align
13 ,null -- p_col_fbv_padding
14);
1EXECUTE SCRIPT API_CFIADM.ADD_LOADER_BD_COLUMN(
2 'PERSON' -- p_ldr_name
3 ,'TESTING' -- p_bdomain
4 ,'LastName' -- p_col_name
5 ,'varchar' -- p_col_data_type
6 ,100 -- p_col_size
7 ,null -- p_col_scale
8 ,null -- p_col_format
9 ,3 -- p_col_pos
10 ,null -- p_col_fbv_size
11 ,null -- p_col_fbv_start
12 ,null -- p_col_fbv_align
13 ,null -- p_col_fbv_padding
14);
Example - column type = ‘decimal’
1EXECUTE SCRIPT API_CFIADM.ADD_LOADER_BD_COLUMN(
2 'PERSON' -- p_ldr_name
3 ,'TESTING' -- p_bdomain
4 ,'Salary' -- p_col_name
5 ,'decimal' -- p_col_data_type
6 ,8 -- p_col_size
7 ,2 -- p_col_scale
8 ,'999G999D99' -- p_col_format
9 ,4 -- p_col_pos
10 ,null -- p_col_fbv_size
11 ,null -- p_col_fbv_start
12 ,null -- p_col_fbv_align
13 ,null -- p_col_fbv_padding
14);
Example - column type = ‘date’
1EXECUTE SCRIPT API_CFIADM.ADD_LOADER_BD_COLUMN(
2 'PERSON' -- p_ldr_name
3 ,'TESTING' -- p_bdomain
4 ,'Birthday' -- p_col_name
5 ,'date' -- p_col_data_type
6 ,null -- p_col_size
7 ,null -- p_col_scale
8 ,null -- p_col_format
9 ,5 -- p_col_pos
10 ,null -- p_col_fbv_size
11 ,null -- p_col_fbv_start
12 ,null -- p_col_fbv_align
13 ,null -- p_col_fbv_padding
14);
Issuing the commands for the different column types above results in the following entries in the table CFI_LOADER_BD_COLUMNS.
LDR_NAME |
BDOMAIN |
COL_NAME |
COL_DATA |
COL_SIZE |
COL_SCALE |
COL_FORMAT |
COL_POS |
---|---|---|---|---|---|---|---|
PERSON |
TESTING |
id |
int |
(null) |
(null) |
(null) |
1 |
PERSON |
TESTING |
FirstName |
varchar |
100 |
(null) |
(null) |
2 |
PERSON |
TESTING |
LastName |
varchar |
100 |
(null) |
(null) |
3 |
PERSON |
TESTING |
Salary |
decimal |
8 |
2 |
999G999D99 |
4 |
PERSON |
TESTING |
Birthday |
date |
(null) |
(null) |
(null) |
5 |
4.2. Modify a CFI Loader Column¶
Modify a loader column using API_CFIADM.MODIFY_LOADER_BD_COLUMN
In the example below the column containing the Birthday is being modified.
A speciic date format is added.
Example
1EXECUTE SCRIPT API_CFIADM.MODIFY_LOADER_BD_COLUMN(
2 'PERSON' -- p_ldr_name
3 ,'TESTING' -- p_bdomain
4 ,'Birthday' -- p_col_name
5 ,'date' -- p_col_data_type
6 ,null -- p_col_size
7 ,null -- p_col_scale
8 ,'YYYY-MM-DD' -- p_col_format
9 ,5 -- p_col_pos
10 ,null -- p_col_fbv_size
11 ,null -- p_col_fbv_start
12 ,null -- p_col_fbv_align
13 ,null -- p_col_fbv_padding
14);
The command above results in a change in the entry of the column ‘Birthday’ in the table CFI_LOADER_BD_COLUMNS, as can be seen below.
LDR_NAME |
BDOMAIN |
COL_NAME |
COL_DATA |
COL_SIZE |
COL_SCALE |
COL_FORMAT |
COL_POS |
---|---|---|---|---|---|---|---|
PERSON |
TESTING |
id |
int |
(null) |
(null) |
(null) |
1 |
PERSON |
TESTING |
FirstName |
varchar |
100 |
(null) |
(null) |
2 |
PERSON |
TESTING |
LastName |
varchar |
100 |
(null) |
(null) |
3 |
PERSON |
TESTING |
Salary |
decimal |
8 |
2 |
999G999D99 |
4 |
PERSON |
TESTING |
Birthday |
date |
(null) |
(null) |
YYYY-MM-DD |
5 |
4.3. Remove a CFI Loader Column¶
To remove a CFI loader column use API_CFIADM.REMOVE_LOADER_BD_COLUMN.
Example
1EXECUTE SCRIPT API_CFIADM.REMOVE_LOADER_BD_COLUMN (
2 'PERSON' -- p_ldr_name
3 ,'TESTING' -- p_bdomain
4 ,'id' -- p_col_name
5);
If the command above is issued for each column name, no entries for the loader ‘PERSON’ with the bdomain ‘TESTING’ should remain in the table CFI_LOADER_BD_COLUMNS.