This topic has been locked.
1 reply Latest Post - 2012-08-14T14:58:45Z by Ivan_CA
Pinned topic Data Loading Failed
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
I was trying to load data from a CSV file into a table in the db2 database, data loading fails. This table has a generated always as identity column, so I am unable to figure out the way to import.
Updated on 2012-08-14T14:58:45Z at 2012-08-14T14:58:45Z by Ivan_CA
Ivan_CA 270002NHNH52 PostsACCEPTED ANSWER
Re: Data Loading Failed2012-08-14T14:58:45Z in response to SystemAdminHi,
It depends on how the file looks like and how you want to handle the identify values. One way of importing is to use the column modifier "ignore input values and create new values":
create table tab1(c1 int generated by default as identity,
alter table tab1 add primary key (c1);
Let's say my input file looks like the file below, but I already have values 1, 2, 3 and 4 for column c1 in my target table, so I want to ignore these values from the file and generate new ones.
When you do the import in Data Studio (Administration Explorer - Tables - tab1 - Load - With Import Utility), after selecting the input file, go to the "Column" tab and select the "Identity column behavior" as "Ignore input file values and create new values". This selection will generate the import statement below, where the 4 rows from the file will be imported with new generated values for column c1.
CONNECT TO DB1;
CALL SYSPROC.ADMIN_CMD( 'IMPORT FROM "/tmp/tab1.del" OF DEL MODIFIED BY identityignore MESSAGES ON SERVER INSERT INTO DB2I10F2.TAB1' );