Insert and updates

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
getsatish_gk
Participant
Posts: 104
Joined: Sat Dec 24, 2005 1:26 am
Location: Bengaluru

Insert and updates

Post by getsatish_gk »

Hi,

I want perform insert if new record or update if exits (don't look for change columns) :wink:

Insert: if primary key does't exist in target ( can do with Change capture code=1)

Update some columns if key exists in target (if i use change capture it looks of change column which i don't want to perform)

Please give me hint. :roll:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Two questions:

1. Does the input data contain duplicate key values?

2. What alternative do you plan for detecting change when the row already exists in the target table?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
getsatish_gk
Participant
Posts: 104
Joined: Sat Dec 24, 2005 1:26 am
Location: Bengaluru

Post by getsatish_gk »

Two questions:

1. Does the input data contain duplicate key values?
A- looking based on primary keys

2. What alternative do you plan for detecting change when the row already exists in the target table? ..
A-If the row exists with same key then i just want to update few columns in target table, thats it.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What I was getting at in the first question is what happens if the same key arrives twice in the stream of input data? How do you need to play this?
You can only insert the first of them.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
getsatish_gk
Participant
Posts: 104
Joined: Sat Dec 24, 2005 1:26 am
Location: Bengaluru

Post by getsatish_gk »

Thanks ray,

Just want to do,
- Insert if primary key is not present. else if present
then set some columns to null.

Can it is possible without change capture/difference stage?.

I checked there are no duplicate key coming from source
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

            RefDS
              |
              |
              V                       ----> insert
source ----> Lookup ----> Transformer
                                      ----> update
Loaded in an earlier job, RefDS contains keys and those columns from the target that you wish to compare. The Lookup stage "lookup failed" rule is Continue. The Transformer stage directs failed lookups to the insert link and detects changes (by direct comparison) where the lookup was successful.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
getsatish_gk
Participant
Posts: 104
Joined: Sat Dec 24, 2005 1:26 am
Location: Bengaluru

Post by getsatish_gk »

Thanks for that. Soon i will be bororw a premier membership.
by then let me try to crack ur code. 8)

Well by now... using join stage with left outer join
with left link=source and right link=target(reference)

and output contains is both new and existing records.

How to distinguish between between these records?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Premium membership is not expensive at less than 30c per day. Don't borrow one, buy one. It will be worth it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
getsatish_gk
Participant
Posts: 104
Joined: Sat Dec 24, 2005 1:26 am
Location: Bengaluru

Post by getsatish_gk »

why i am worried is when ever i post mostly get reply only from you. No other will reply.. this :oops: me
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Maybe no-one else is silly enough to work weekends.
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 »

:lol:

Techincally, you've got 20,000+ people who could help you out here, however the vast majority only seem to post when they have a problem. It's a very small group that try to help others, but that's the way it is anywhere, the nature of the beast. And when the Alpha Male steps in, almost everyone else steps back from the kill and lets him have his fill. :wink:

Or maybe no-one else is silly enough to work weekends.
Last edited by chulett on Sun Sep 07, 2008 5:50 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
getsatish_gk
Participant
Posts: 104
Joined: Sat Dec 24, 2005 1:26 am
Location: Bengaluru

Post by getsatish_gk »

Yeah, Most of them just waiting for pulling someothers leg :x

When the things not working, have to work even on nights :(
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are only five premium posters, one of whom is currently sailing (or riding out storms) in the Caribbean. Anyone else with constructive thoughts on any issue is welcome to post, but it's their choice whether they do or not.

Anyway, don't you have an official support provider?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply