unique constraint error

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
dnat
Participant
Posts: 200
Joined: Thu Sep 06, 2007 2:06 am

unique constraint error

Post by dnat »

Hi,

I have a server job and have the target table as an oracle stage. I am doing inset/update (insert new rows or upsert existing rows). But still i am getting this oracle error
ORA-00001: unique constraint (CVID_UAT.PK_CV_WE_PRE_INSPECT) violated
Ideally we should not get this in an upsert mode, isnt it?
swarnkar
Participant
Posts: 74
Joined: Wed Jan 11, 2006 2:22 am

Re: unique constraint error

Post by swarnkar »

dnat wrote:Hi,

I have a server job and have the target table as an oracle stage. I am doing inset/update (insert new rows or upsert existing rows). But still i am getting this oracle error
ORA-00001: unique constraint (CVID_UAT.PK_CV_WE_PRE_INSPECT) violated
Ideally we should not get this in an upsert mode, isnt it?
Your Update statement is getting failed so Datastage is trying to insert the record. Check your update query.

If Update query fails, for any reason system would go for insert.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ideally you shouldn't ever get any errors in any mode. :wink:

Insert/Update means the insert is first attempted and if it fails an update is attempted. In order for the insert to fail there must be a unique index / primary key on the target that gets violated. However, any error reported from this operation is from the second action not the first and the way you get a unique constraint violation from an update is if you are updating keys bound into a unique index to a value that already exists.
Last edited by chulett on Fri Jan 16, 2009 9:03 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Katie09
Participant
Posts: 15
Joined: Sun Jan 11, 2009 5:45 pm
Location: Sheffield

Post by Katie09 »

Yes...this error should be not be there for upsert mode..
however check the constraints on the table and the keys used for the updation...table might have more than one contraint which might be violated by the data which you are proessing..

hope this helps..
srinagesh
Participant
Posts: 125
Joined: Mon Jul 25, 2005 7:03 am

Post by srinagesh »

try update else insert
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

so many answers going on...

DNAT, Did you add the sub property "Insert Array Size" and set it to 1 in Oracle EE stage?
Kandy
_________________
Try and Try again…You will succeed atlast!!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Server job, so no "EE" stage here. And the OCI stage will automatically drop the array size down to 1 if it is not already there when using these combo actions.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

Sorry Craig. I overlooked.
Kandy
_________________
Try and Try again…You will succeed atlast!!
dnat
Participant
Posts: 200
Joined: Thu Sep 06, 2007 2:06 am

Post by dnat »

hi,

my update clause had two keys(in the where clause as well as keys indicated in the metadata) but the table had only one key. I think this has caused the updated to fail. I am yet to do the full testing, but since i had to complete the task in a hurry, i deleted the records which had to be insert/update and reran the job..all the records were inserted properly..

so, here as craig said the issue happens to be with the update statement.
Post Reply