regarding surrogate key generation

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
Saama
Premium Member
Premium Member
Posts: 83
Joined: Wed Nov 22, 2006 6:42 pm
Location: Pune
Contact:

regarding surrogate key generation

Post by Saama »

hi,
iam using ODBC----->TRANSFORMER---->ODBC.
in the o/p stage, i created extra column called id for surrogate key.
i have defined a stage variable called SV and intialized to 1
i have called routine called keymanagement next value and it has parameter called sequencer name.
what shall i enter in the place of sequence name.
plz help me, what shall be the derivation for the o/p column ID .

o.p column id-name of the surrogate key column.


cheers;
saama
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

The derivation should be KeyMgtGetNextValue(SeqName) where SeqName is nothing but a name that identifies this particular sequence.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Saama
Premium Member
Premium Member
Posts: 83
Joined: Wed Nov 22, 2006 6:42 pm
Location: Pune
Contact:

Post by Saama »

hi,
thanks gurus, i really appreciate.
keymanagementnextvalue(@INROWNUMBER)=id
constraint=@inrownumber<10
stage variable 'sv' and assigned to 1.
when i compile and run.its running fine, and iam able to generate surrogate key , the sequence is 3,4,5,6. why iam not getting from 1,2,3,4,5... .plz help me. what shall i do inorder to get surrogate key from 1,2,3,4,5..

plz help me.
cheers;
saama
Saama
Premium Member
Premium Member
Posts: 83
Joined: Wed Nov 22, 2006 6:42 pm
Location: Pune
Contact:

Post by Saama »

hi,
thanks gurus, i really appreciate. i have given incomplete information.
in the transformer stage, i have given,
keymanagementnextvalue(@INROWNUMBER)=id
where id is the o/p column in my target stage which i defined manually
constraint=@inrownumber<10
stage variable 'sv' and assigned to 1.
when i compile and run.its running fine, and iam able to generate surrogate key , the sequence is 3,4,5,6. why iam not getting from 1,2,3,4,5... .plz help me. what shall i do inorder to get surrogate key from 1,2,3,4,5..

plz help me.
cheers;
saama
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Dont provide @INROWNUM as the sequence name. Give a sensible name. Like maybe JobName. Why do you need the stage variable 'sv' again. If you dont, then get rid of it.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Saama
Premium Member
Premium Member
Posts: 83
Joined: Wed Nov 22, 2006 6:42 pm
Location: Pune
Contact:

Post by Saama »

hi gurus,
when i used KeyMgtGetNextValue(drs14*)=id
here id is the o/p column name
drs14= jobname
iam getting error =" variable drs14 is not defined"
i tried various other ways.
only when i use keyMgtGetNextValue(@INROWNUMBER)
I could validate the expression.
but can generate sequences from 3, 4,5,6..
what should i use inorder to validate my expression and need to generate from 1,2,3,4....

plz help me.
cheers;
saama
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Quote the sequence name.

Code: Select all

KeyMgtGetNextValue('drs14')
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Saama
Premium Member
Premium Member
Posts: 83
Joined: Wed Nov 22, 2006 6:42 pm
Location: Pune
Contact:

Post by Saama »

hi gurus,
Thanks very much its working fine.

cheers;
saama
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can now mark the post as resolved.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply