increment counter

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
sdfasih
Participant
Posts: 39
Joined: Wed May 24, 2006 7:22 pm

increment counter

Post by sdfasih »

Hi,
I would like a counter to be loaded in a field.
For ex:-
First run
Record1 counter=1
Record2 counter=2 so on
Second run
Record1 counter=1
Record2 counter=2 so on
Every time job is run counter should be intialized to 1.
I used KeyMgtGetNextValue function but its not intializing counter to 1 at the start of second run.
Thanx.
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Use @INROWNUM.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Course not, that's not what it is for. <smack> :wink:

Use that when you need it to pick up from where it left off last time. Use one of the ROWNUM system variables:

@INROWNUM
@OUTROWNUM


Read the online help available for them so you understand the difference.
-craig

"You can never have too many knives" -- Logan Nine Fingers
devilsmentor
Participant
Posts: 30
Joined: Wed Apr 12, 2006 11:23 am

Re: increment counter

Post by devilsmentor »

Try Modifying the routine. Open the routine and click on the 'CODE' tab. Then comment the last line in the code that reads

"Writeu NextVal On SeqFile, Arg1 Else Ans = -1". Put an asterisk * in front of it .


This routine may not modify as it is built-in, try copying the code and paste it in a new routine. Name it and OWN IT !!! :twisted:
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Thats not necessary and extra work + unnecessary maintenance. As pointed out @INROWNUM and @OUTROWNUM can accomplish the task.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Don't even think about editing that routine - create a copy and edit that version if you want to try that. Anyone already using it will thank you... actually, they won't kill you. (I feel like I may have just saved a life today) :P
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

That routine cannot be edited anyways. Right :roll: ?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

They all can edited unless someone specfically goes and makes them RO.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Which is the case in most places. I have always seen them as RO and hence my assumption.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

chulett wrote:They all can edited unless someone specfically goes and makes them RO.
:o

I'm not able to edit it. :wink: . But I believe nobody made them RO. I always thought that sdk routines were un-editable. Am I assuming wrong here? :?
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
devilsmentor
Participant
Posts: 30
Joined: Wed Apr 12, 2006 11:23 am

Post by devilsmentor »

Alright let me take all the pain to explain you in peace.
1. Right click on routines tab in ur repository
2. choose "New Routine"
3. Name it "XYZ" and paste the code that you copied from the earlier one.
4. Now edit it as you wish, and dont forget to change the filename in which the data will be written.
5. This way no one will kill you if someone is already using it.
6. Or you can use the @INROWNUM/@OUTROWNUM as suggested.
7. And i mentioned already that you cannot edit the built-in ones, so NAME IT AND OWN IT.

This is the deal !!! You ask for one and we give you many. Cheers :D . OHHH I LOVE THIS PLACE :idea:
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

devilsmentor wrote:Alright let me take all the pain to explain you in peace.
1. Right click on routines tab in ur repository
2. choose "New Routine"
3. Name it "XYZ" and paste the code that you copied from the earlier one.
4. Now edit it as you wish, and dont forget to change the filename in which the data will be written.
5. This way no one will kill you if someone is already using it.
6. Or you can use the @INROWNUM/@OUTROWNUM as suggested.
7. And i mentioned already that you cannot edit the built-in ones, so NAME IT AND OWN IT.

This is the deal !!! You ask for one and we give you many. Cheers :D . OHHH I LOVE THIS PLACE :idea:
Hi,
I'm not the OP. :wink: I was just trying to determine whether the sdk routines are RO or NRO by default.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
devilsmentor
Participant
Posts: 30
Joined: Wed Apr 12, 2006 11:23 am

Post by devilsmentor »

Yes sir, They are RO
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

True, they are. Sorry. I was confused there for a moment and thinking about other routines. Keep the advise more as general advise not to make changes to existing routines unless you own them and are aware of the impact the change will have on every job that uses them.

Otherwise, you're just asking for trouble.
-craig

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