Hi All,
I have one interesting requirement. There are two unique indexes defined on a table. My program deals with inserts and deletes. This program is a kind of delta process to keep target tables in sync with Source tables.
Basically if insert fails, this program deltes the old record and insert it again. (To keep the updates on source table in target table.).. offcourse..this is just a logic. and there is some other stuff too. If key K1 is duplicated, delete the old record and insert the new one. If key k2 is duplicated, then abend the job. So when i get -803 i need to know which Key K1 or K2 caused the negative error code. Hope this is clear
My question is.
If i get -803 while inserting, I need to find out which key resulted in duplicate insert. As i mentioned there are two unique keys.
I have two solutions at this point of time.
1. If we use DSNTIAR to get the diagnostic information it would give the index name, based upon this index name we can figure out which key caused the duplicate. However i dont want to use this method since i have to invoke this error routine whenever i get -803.
2. When i get -803, put a select statement with where predicate for key K2. if it exists abend the job or else continue with the usual process.
Most of the times, My program deals with 80% of the updates. So i dont want to go by the above two methods as it is going to be additional overhead.
Is there any way i can find out the column no or column name directly with out doing the above said process.
Note: The above two methods are just upto my knowledge. If you guys have any additional logic that would be really great for me.
Please correct me if am wrong.
Thanks,
Vinay