keep old values in columns when updating Oracle table?

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
sattibabu_2004
Participant
Posts: 6
Joined: Thu Oct 12, 2006 1:05 pm

keep old values in columns when updating Oracle table?

Post by sattibabu_2004 »

I am using Server jobs. I have to read XML file with 15 tags as input to update exisitng Oracle table with 15 columns. All XML tags are optional except ID(primary key) column. So, Each XML message is not neccesserily containing all values in all messages. If mesage 1 comes with column 4 with null value and other fileds with valid values, I have to update with new values in table with values from XML except for column 4. I am not sure till message comes to processing which field is coming as null. In summary I can say that, if one field is null in input I want ot keep the exisitng value for the corresponding column in table's row, but update other columns for that row. I have to use only one job. How can I solve my problem? I can't use PX in this case for other reasons. Thank you for your help.
dsdev750
Charter Member
Charter Member
Posts: 16
Joined: Sat Jun 04, 2005 10:19 am

Post by dsdev750 »

You could have a user-defined update statement like:

UPDATE tbl
SET col1 = NVL(:col1, col1),
col2=NVL(:col2, col2)..
WHERE pk_col=:pk_col
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. :D

Perform a lookup against the target table, or a hashed file containing relevant rows and columns from the target table. This will allow you to determine the current values, which you can use in the UPDATE statement if the source value is null.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sattibabu_2004
Participant
Posts: 6
Joined: Thu Oct 12, 2006 1:05 pm

Post by sattibabu_2004 »

ray.wurlod wrote:Welcome aboard. :D

Perform a lookup against the target table, or a hashed file containing relevant rows and columns from the target table. This will allow you to determine the current values, wh ...

It worked. Thank you all for your help.
Post Reply