Sequence number within the Job

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
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Sequence number within the Job

Post by paranoid »

Hi,

We have a requirement where we need to send a file on a daily basis and on the header part of that file we need to include a sequence number in the following format:
'000000001' and it should increment for every run.

Is there any easier way to implement this with in a job?

Any help is appreciated.

Sue :)
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Use the julian date in a 6 digit format.
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Thanks Sai. Can you please let me know how to do this?

Sue
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Assuming you are calling it from a sequencer, you can give the output file name as

Code: Select all

pYourOutputFileName : '_' : Fmt(OConv(@Date,'DJ'),"6'0'R")
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Sai,

Thanks for the reply. Infact i could get the sequence number using sequencer in oracle. I am getting the numbers as '1','2' etc;

Is there any simple way to convert this to 9 digit format with 'zeroes' in front of that number?

1 ---->000000001
11 ---->000000011

Thanks

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

Post by chulett »

In your Oracle select, use to_char() with the appropriate mask to select it in that format. Inside the job, lpad() would do the trick.
-craig

"You can never have too many knives" -- Logan Nine Fingers
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Thanks Chulett. I have tried the below function and it seems to be giving the correct output:

FMT(DSLink34.SEQ_NO,"R%9")

Please correct if i am wrong.

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

Post by chulett »

True, FMT would be another option. I don't recall what '%' means off the top of my head, I would usually specify a zero as the pad character:

Code: Select all

FMT(DSLink34.SEQ_NO,"R'0'9")
-craig

"You can never have too many knives" -- Logan Nine Fingers
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Thank you again. '%' is giving me the desired result :) .

Have a nice day!!

Sue
Post Reply