If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > turn on foreign keys

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-09-06, 16:13
jinsezh jinsezh is offline
Registered User
 
Join Date: Aug 2006
Posts: 33
Question turn on foreign keys

Hi there,

I wonder when you turn on the foreign key constraint, is there a way to just get the report which row has the violation, without physically delete and move the row to the exceptional table?

Thanks
Reply With Quote
  #2 (permalink)  
Old 11-09-06, 23:10
manish21 manish21 is offline
Registered User
 
Join Date: Jan 2003
Posts: 35
You will have to export the data to some external csv or delimited file. Then drop the table and recreate it again and try loading the data using load command using the for exception option of the load command and specify the name of the exception table in which the rows violating the constraint will be inserted.
Reply With Quote
  #3 (permalink)  
Old 11-11-06, 17:17
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by jinsezh
I wonder when you turn on the foreign key constraint, is there a way to just get the report which row has the violation, without physically delete and move the row to the exceptional table?
Assuming you're on z/OS, just use the "delete no" option of the "check data" utility.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #4 (permalink)  
Old 11-15-06, 17:37
jinsezh jinsezh is offline
Registered User
 
Join Date: Aug 2006
Posts: 33
Quote:
Originally Posted by Peter.Vanroose
Assuming you're on z/OS, just use the "delete no" option of the "check data" utility.
Here is the syntax for check data:
.-----------------------------------. |
| V | .-DELETE--NO----------------. |
'-FOR--EXCEPTION----IN--table-name1--USE--table-name2-+--+---------------------------+-'
| .-LOG--YES-. |
'-DELETE--YES--+----------+-'
'-LOG--NO--'

Sorry, I don't know how much you can see it , but anyway, should I still create and specify the exception table "table-name2"?

Basically I just want to check which rows have the violation and don't want to make any data changes.
Reply With Quote
  #5 (permalink)  
Old 11-16-06, 10:53
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by jinsezh
Basically I just want to check which rows have the violation and don't want to make any data changes.
In that case, just don't use any "FOR EXCEPTION" or "DELETE" options in the statement.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On