how to create unique sequence no with reference to primary

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
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

how to create unique sequence no with reference to primary

Post by pxraja »

Hi all,

requirement is like this,

Unique numbers should be generated based upon the composite primary keys. for example,

Inlink.Field1 Inlink.Field2 Inlink.Field3 Inlink.Field3
65465 'kjdjfsak' 5645 'kjdfoi'
68845 'doewlks' 8556 'dkgjioe'
65465 'eujdskd' 6455 'doewl'

Outlink.Field1 Outlink.Field2 Outlink.Field3 Outlink.Field4 Outlink.Field5
1 65465 'kjdjfsak' 5645 'kjdfoi'
2 78845 'doewlks' 8556 'dkgjioe'
3 65465 'eujdskd' 6455 'doewl'

where Inlink.Field1 and Inlink.Field3 are primary keys
and Outlink.Field1 is the Unique Field

any ideas are welcome

Thanks in Advance
brvishwas
Participant
Posts: 2
Joined: Tue Nov 21, 2006 1:12 am

Post by brvishwas »

Use @inrownum function in the transformer.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Use the routine KeyMgtGetNextValueConcurrent for getting Sequence number.

Do whatever mechanism in your job to identify the unique string, use order by in your sql , and use stage variables to identify the uniqueness, or use a lookup to idetify the uniqueness.

and for the unique value, just call the routine as KeyMgtGetNextValueConcurrent('whateverstring') , this will give you the unique sequence number.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I'd prefer to use the system variable @OUTROWNUM, particularly if you're using a constraint expression on the output.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

Post by pxraja »

DS_SUPPORT wrote:Use the routine KeyMgtGetNextValueConcurrent for getting Sequence number.

Do whatever mechanism in your job to identify the unique string, use order by in your sql , and use stage variables to identify the uniqueness, or use a lookup to idetify the uniqueness.

and for the unique value, just call the routine as KeyMgtGetNextValueConcurrent('whateverstring') , this will give you the unique sequence number.
sequence should start with 1 and its should be incremented by 1 when using the KeyMgtGetNextValueConcurrent('Whateverstring'), will it provides incremental value from the last sequence? how to get the value of the last sequence and on the next run the sequence should start with last sequence value +1

Any suggestions are welcome

Thanks in Advance
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Yes, Your sequence number will start with 1, and for the next run also, it will give you the next max number. You dont have to do any extra settings for achieving this.

But when using, consider changing 'whateverstring' to some meaningful string.
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

Post by pxraja »

DS_SUPPORT wrote:Yes, Your sequence number will start with 1, and for the next run also, it will give you the next max number. You dont have to do any extra settings for achieving this.

But when using, consider changing 'whateverstring' to some meaningful string.
While running a new job with KeyMgtNextValueConcurrent(1), the sequenct number is starting with lastMax Sequence used in some other job. How to make the new job to start with the sequence starts with 1 and how to maintain the sequence for that particular Job.

I want to use KeyMgtNextValueConcurrent(1) for Job wise, but it is taking the value from project wise.

Any suggestions are welcome

Thanks in Advance
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a different sequence name. The sequence name is the argument to this routine. You are using a sequence named "1" in both jobs. Don't.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Use KeyMgtNextValueConcurrent(YOURJOBNAME), so it will maintain sequence based on each job.
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

Post by pxraja »

Hi All,

I had used seq(1) got into a stagevariable, and used that stagevariable in KeyMgtNextValueConcurrent(StgVar) it's getting sequence starting from 1..

Its resolved..

Thanks for your suggestions.
Post Reply