Cesar
Cesar

Reputation: 1610

Import data in derby with identity id

I am importing data to derby using SYSCS_IMPORT_DATA. My table has an identity columns that i want to keep because it is referenced in other tables.

I keep getting the error:

Attempt to modify an identity column

using the following call

CALL SYSCS_UTIL.SYSCS_IMPORT_DATA (NULL,'TABLE',NULL,NULL,'DATA.DEL',NULL,NULL,NULL,0);

Upvotes: 2

Views: 1942

Answers (2)

Moreno
Moreno

Reputation: 546

You can keep the "GENERATED ALWAYS" in your tables. The solution is that you have to specify in the call those columns that you want to import in the table, excluding those that are identity columns.

Example:

CALL SYSCS_UTIL.SYSCS_IMPORT_DATA (null, 'STAFF', 'NAME,DEPT,SALARY,PICTURE', '2,3,4,6', 'c:\data\staff.del', ',','"','UTF-8', 0);

The third parameter of the call are the columns names, and the fourth their order in the table.

More info at this link:

http://db.apache.org/derby/docs/10.6/tools/ctoolsimportidentitycol.html

Hope this helps in the future, Marcos.

Upvotes: 0

Cesar
Cesar

Reputation: 1610

Well, i found my answer. The problem was the table, just changed the GENERATED ALWAYS for GENERATED BY DEFAULT.

Upvotes: 3

Related Questions