Mohd Arshil
Mohd Arshil

Reputation: 305

Foreign key Constraints issue in DB2 SQL replication

While implementing DB2 SQL replication we came to know that apply program was not able to judge the foreign key dependency while applying the changes in target database hence before inserting the data in target table with primary key it was trying to insert the data in table with foreign key.

The consequences were failures of insert operation for some records in the tables with foreign key applied on them.

As a solution we try to include these tables each in different subsets with applied script scheduled each individually for this set. But still as the scripts are concurrently running we were facing same issue.

Is there any solution for this problem or we need to remove the foreign keys and perform the implement the replication.

Upvotes: 0

Views: 869

Answers (2)

GeekyDaddy
GeekyDaddy

Reputation: 384

Not quite sure what you are trying to do. But it looks like your trying to import data into a table where the relational dependency are not available at the time of import.

Using the LOAD command. You can import the table using the SET INTEGRITY PENDING CASCADE DEFERRED this will allow you to import all the data into the table. Once you have imported the other tables which are required for the dependency you can then remove if from INTEGRITY PENDING state. Here is an article about removing it from this state https://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.admin.dm.doc/doc/c0004593.html

Upvotes: 0

mustaccio
mustaccio

Reputation: 19001

Since your constraints are supposedly enforced on the source database, you can safely set the foreign key constraints on the destination to NOT ENFORCED, which should eliminate the constraint violation errors. Since you did not provide your DB2 platform and version, you'll have to look up the correct syntax of the ALTER TABLE statement in the appropriate manual yourself.

Upvotes: 0

Related Questions