Sequence number

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
veera24
Premium Member
Premium Member
Posts: 150
Joined: Thu Feb 07, 2008 9:37 pm
Location: NewYork

Sequence number

Post by veera24 »

hi all,
I'm in need to generate sequential number based on the follwing criteria.

If my record starts with '6' then i got to generate the number starting from '01' and If the record starts with some other number then it should be one.
Here the main criteria is the records starting with '6' wont be in order. I mean the records with other than '6' will also be in middle.At that time the sequence number should be genrated from the previous value being generated.

For example.
Input --> Sequence number

623 then 01
640 then 02
590 then 01
875 then 01
634 then 03
627 then 04


Could any one suggest me how to generate the same.

Your time will highly appreciated.

Thanks in advance,
Veera
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

Have two stage variable namely svInd and svCnt.

Derivation for svInd

Code: Select all

If InRec.Col1[1,1]=6 then @TRUE else @FALSE
I had assumed that the input is a string.

Derivation for svCnt

Code: Select all

If svInd then svCnt + 1 else svCnt
In your output column derivation have the following code:

Code: Select all

If svInd then svCnt else 1
You need not sort data.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:!: Nit pick alert!

You do not need to specifically set an expression to "true" or "false", that is automatic when it is evaluated. So rather than the derivation posted for svInd, it can simply be:

Code: Select all

InRec.Col1[1,1]=6
FYI.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use the Fmt() function to add leading zeroes. Beware, however, that this will give "strange" results if your count goes over the number of digits you specify in your format string.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

Thanks Craig for your useful alert. :)
veera24
Premium Member
Premium Member
Posts: 150
Joined: Thu Feb 07, 2008 9:37 pm
Location: NewYork

Post by veera24 »

balajisr wrote:Thanks Craig for your useful alert. :)
As i don't have the membership i couldn't see chulett's comment. So could you pls. help me out to get to know. :( :(

Thanks in advance,
Veera
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

veera24 wrote:
balajisr wrote:Thanks Craig for your useful alert. :)
As i don't have the membership i couldn't see chulett's comment. So could you pls. help me out to get to know. :( :(

Thanks in advance,
Veera
I am sorry.It is not fair to post premium content.

Why don't you buy premium membership. Certainly worth it.
veera24
Premium Member
Premium Member
Posts: 150
Joined: Thu Feb 07, 2008 9:37 pm
Location: NewYork

Post by veera24 »

balajisr wrote:
veera24 wrote:
balajisr wrote:Thanks Craig for your useful alert. :)
As i don't have the membership i couldn't see chulett's comment. So could you pls. help me out to get to know. :( :(

Thanks in advance,
Veera
I am sorry.It is not fair to post premium content.

Why don't you buy premium membership. Certainly worth it.
Hi,
Its ok at the least you can guide me right?instead posting Chulett's comments.

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

Post by chulett »

Balajisr has already guided you. Nothing I added fundamentally changed what he said.
-craig

"You can never have too many knives" -- Logan Nine Fingers
veera24
Premium Member
Premium Member
Posts: 150
Joined: Thu Feb 07, 2008 9:37 pm
Location: NewYork

Post by veera24 »

chulett wrote:Balajisr has already guided you. Nothing I added fundamentally changed what he said. ...
Yeah thanks chulett.
Thanks in advance...
veera...
Post Reply