How does upsert or Update exisiting or insert new recs work

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
dsnovice
Participant
Posts: 38
Joined: Thu Jul 22, 2004 11:56 pm
Location: Mclean, VA
Contact:

How does upsert or Update exisiting or insert new recs work

Post by dsnovice »

I have two parallel streams in a server job writting records to common table. The two streams have the same set of keys (Key 1,Key 2), but populate some over lapping fields (LOAD_DATE) and two stream specific fields (SRC & TGT).

The problem is, lets say there are 50 records from stream 1 and 50 records from stream two, Stream 1 is able to update or insert all 50 records and Stream 2 manages to update or insert only 48. Two records are not updated.

Data Stream 1

Key 1, Key 2, SRC_AMT, SRC_PRODUCT, LOAD_DATE
1 A 100.00 Type 1 Nov 1st, 2009
2 A 200.00 Type 2 Nov 1st, 2009
....
....

Data Stream 2

Key 1, Key 2, TGT_AMT, TGT_PRODUCT, LOAD_DATE
1 A 100.00 Type 1 Nov 1st, 2009
2 A 200.00 Type 2 Nov 1st, 2009
....
....

When I check in the table

Key 1, Key 2, SRC_AMT, SRC_PRODUCT, TGT_AMT, TGT_PRD, LOAD_DT
1 A 100.00 Type 1 100.00 Type 2 Nov 1st, 2009
2 A 200.00 Type 2 (null) (Null) Nov 1st, 2009

there are No warning messages in the job logs, indicating any errors or rejects.

So back to my question, how does upsert or Update existing or Insert new rows work in the back end?
1. Does it execute a select statement on the table to check if the record exists, if it does then insert else send in update statement?
2. Does it simply execute the update statement, if it gives a negative return code then execute the insert statement?

Thank you,

a novice..
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No documented information is available on this quesion. I used to believe that your second option was the way it works, but have no way to be certain.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

For any of the 'combo' actions, the first action is executed and if it fails, then the second is executed. The update "fails" if it updates zero records.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dsnovice
Participant
Posts: 38
Joined: Thu Jul 22, 2004 11:56 pm
Location: Mclean, VA
Contact:

Post by dsnovice »

The dba says he doesn't see any rejects or negative codes. Plus he said the transaction Isolation levels, like cursor stability to Repeatable read only are effective on Selects. Since they have the same choices in Input side, I thought there was a select done some where..

Thank you for clarifying the doubt.. I will assume its as you guys said.

Thank you,

A novice
Post Reply