How to increment the value in Database while updating table

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
AnushaReddy
Participant
Posts: 13
Joined: Thu Dec 02, 2010 2:55 am

How to increment the value in Database while updating table

Post by AnushaReddy »

Hi,

If new employee need to insert the following columns:
No_Of_tries=1
Pro_Id = ID
OriPro_Id = Null

If existing employee need to Update the following columns :
No_Of_tries= No_Of_tries+1
Pro_Id = ID
OriPro_Id = Prev_ID

How to update the table by incrementing the value , can you please suggest...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.

This kind of problem is usually solved with stage variables, whose derivation expressions can include If..Then..Else logic and which can be given initial values.

For example svNoOfTries might be derived as

Code: Select all

If svNewEmployee Then 1 Else svNoOfTries + 1
Of course, I do not know your business logic for "new employee", but I'm sure that such must exist.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
AnushaReddy
Participant
Posts: 13
Joined: Thu Dec 02, 2010 2:55 am

Post by AnushaReddy »

Thanx....If it is just inserting i would have done in stage variable but here i need to insert and update so how to do....

Thanks,
Anu
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Use a lookup so you know both if it is "new" or not and what the old values are. Then you can either insert or update and increment the old values appropriately.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply