Page 1 of 1

How to increment the value in Database while updating table

Posted: Thu Dec 02, 2010 3:11 am
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...

Posted: Thu Dec 02, 2010 4:59 am
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.

Posted: Thu Dec 02, 2010 5:24 am
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

Posted: Thu Dec 02, 2010 8:49 am
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.