I am trying to create/select an Db2 external table with the FIXED format, but whitout any success.
Here is what I have tried:
From an IBM pdf (https://www.tridex.org/wp-content/uploads/Db2ExternalTables_Tridex.pdf page 21):
db2 "CREATE EXTERNAL TABLE TABLE1_FIXED (col1 int, col2 varchar(20)) USING (DATAOBJECT '/home/myuser/myfile.fixed' FORMAT FIXED LAYOUT(REF BYTES 1,col1 BYTES \@1, col2 varchar(20) BYTES 4) RECORDLENGTH \@1+6)"
DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:
SQL0007N The statement was not processed because a character that is not supported in SQL statements was included in the SQL statement. Invalid character: "\". Text preceding the invalid character: "F BYTES 1,col1 BYTES".
SQLSTATE=42601
I have tried many things concerning this SQL query, without any success.
I have also tried to create an external table from a simple table:
[i1156@pc-l-0037(el040701_dev:) ~]$ db2 "create table TABLE (col1 char(1) not null)"
DB20000I The SQL command completed successfully.
db2 "CREATE EXTERNAL TABLE TABLE_EXT (col1 char(1) not null) USING (DATAOBJECT '/home/myuser/TABLE.fixed' FORMAT FIXED LAYOUT(col1 char(1)) RECORDLENGTH 1)"
DB20000I The SQL command completed successfully.
cat TABLE.fixed
abc
db2 "select * from TABLE_EXT"
SQL1476N The current transaction was rolled back because of error "-5199".
SQLSTATE=40506
The external table creation seems to be okay, but when I run a 'select *' on this external table, I got the SQL1476N error.
I hope someone could help me ;) Thanks