Increment Row value by 1

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
rahulds
Participant
Posts: 9
Joined: Mon Jun 16, 2008 9:26 am

Increment Row value by 1

Post by rahulds »

I am trying to load a file into a table...whenever i load each ROW i need to increment the INTFC_ID value by 1. .how can i do this..? :(
RAHUL
DataStage Developer
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Are you appending to the table you are loading?

If not then you can just create a counter in a stage variable.

Stage Variable = svCounter (set default value to 1)
Derivation = svCounter + 1

If you are appending then you will need to get the max INTFC_ID and start from that.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

You can use @INROWNUM in your derivation directly, if you dont want to continue from the last used value.

And if you want to use from your last used value, consider writing the final value to a Hashed File, and pass the value as job parameter for the next run.
rahulds
Participant
Posts: 9
Joined: Mon Jun 16, 2008 9:26 am

Post by rahulds »

DS_SUPPORT wrote:You can use @INROWNUM in your derivation directly, if you dont want to continue from the last used value.

And if you want to use from your last used value, consider writing the final value to a Hashed File, and pass the value as job parameter for the next run.
@INROWNUM will not work in my case because if any ROW is rejected then the increment is not one.
RAHUL
DataStage Developer
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why did you not mention this added requirement in your original question?

Then you have no solution if this integer is your key. If this integer is not the primary key, then you could have an after insert trigger to generate its value from a sequence. DataStage can not provide something that depends on an event that occurs after DataStage has sent the row to the database server.

A better design, if you insist upon DataStage generating the integer, would be to guarantee that rows can be successfully inserted before they leave DataStage - that is, to check all security and integrity constraints within DataStage and handle the rejects before sending the row to the database server.
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