Insert and update

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
rafidwh
Participant
Posts: 179
Joined: Mon Oct 10, 2005 11:30 pm

Insert and update

Post by rafidwh »

Hi All,
I need to update or insert new rows based on key columns.
I need to do some calculation on the updated records before populating into the table.So I am taking two links from the transformer one for insert and the other for update and oci as my lookup.
I gave the condition in the constraint like IsNull(keycolumn) for insert and NotIsnull for update.
The update actions choosen from the oci are insert new rows and update existing rows respectively
But my concern is even when I am trying to populate new record it is going through the update link.

Any suggestion Please

Regards.
Saik
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Re: Insert and update

Post by kris007 »

rafidwh wrote: I gave the condition in the constraint like IsNull(keycolumn) for insert and NotIsnull for update.
Is the keycolumn from the input link or the reference link. I usually differentiate between updates and inserts using the LinkVariables with the following condition in the Constraint

Code: Select all


Updates-->  InputLink.NOTFOUND <> @TRUE
Inserts-->   InputLink.NOTFOUND = @TRUE
I would also suggest you use hashed file as your lookup instead of OCI stage for performance benefits.

HTH
Kris

Where's the "Any" key?-Homer Simpson
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Re: Insert and update

Post by DSguru2B »

rafidwh wrote: I gave the condition in the constraint like IsNull(keycolumn) for insert and NotIsnull for update.
The keycolumn must be from the reference link and not from the source or else it will always go down the path of Update.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Do you have Not(IsNull(keycolumn)) as (part of) the constraint on the update link?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Alagusakthivelan
Participant
Posts: 19
Joined: Tue Apr 26, 2005 11:41 pm

Post by Alagusakthivelan »

Hi

Updates--> InputLink.NOTFOUND <> @TRUE
Inserts--> InputLink.NOTFOUND = @TRUE

this will not allow in OCI reference stage, even though it shows it wont take the correct records. use IsNull for OCI stage reference.

check the constraint value in stage variable and use the stage variable in constraint.
rafidwh
Participant
Posts: 179
Joined: Mon Oct 10, 2005 11:30 pm

Post by rafidwh »

yes Ray
I defined the key colunm in constraint for update as

Not(IsNull(srckeycolumn))
rafidwh
Participant
Posts: 179
Joined: Mon Oct 10, 2005 11:30 pm

Post by rafidwh »

And I have 8 key coluns based on that I need to update or insert
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

rafidwh wrote:yes Ray
I defined the key colunm in constraint for update as

Not(IsNull(srckeycolumn))
Change it to something like
Not(IsNull(lkpkeycolumn))
and your problem should get resolved.
Success consists of getting up just one more time than you fall.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

rafidwh wrote:And I have 8 key coluns based on that I need to update or insert
In that case InputLink.NOTFOUND should be your simple option, instead of give 8 different condition.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

You need to give it condition for insert like InputLink1.NOTFOUND or InputLink2.NOTFOUND and ..... Upto 8 links and for Update NOT(InputLink1.NOTFOUND and InputLink2.NOTFOUND and ... Upto 8 )
above should be fine..

Thanks,
Anupam
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

sb_akarmarkar wrote:You need to give it condition for insert like InputLink1.NOTFOUND or InputLink2.NOTFOUND and ..... Upto 8 links and for Update NOT(InputLink1.NOTFOUND and InputLink2.NOTFOUND and ... Upto 8 )
above should be fine..

Thanks,
Anupam
Anupam - It is 8 Keys and not 8 links.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply