Surrogate Key -- Database Sequence

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Murali4u
Participant
Posts: 37
Joined: Sun Feb 21, 2010 12:27 pm

Surrogate Key -- Database Sequence

Post by Murali4u »

Dear all,
Two questions:

1. I could establish the Surogate key generation through flat file. Can you explain how to generate it through DB2 sequence.


2. I have a scenario:
Input : Dataset -- 2 million records contains (empname,esal)
In target DB2 table say EMP (empid is a sequence generator).

For every record in dataset, i want to capture the sequence number plus the value of employee in another dataset without inserting it into the target table..

so my target dataset should be (empid generated sequence no from table, empname, esal)

Can you explain me how to achieve this in parallel.. Thank you..
Rockzz Tech
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Use the Surrogate Key Generator stage and set the Source Type option to Database Sequence. Then fill in the appropriate connection and output column information.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
soumya5891
Participant
Posts: 152
Joined: Mon Mar 07, 2011 6:16 am

Post by soumya5891 »

You can generate surrogate key from a surrogate key generator stage and also from transformer fro DB sequence.And give the proper database related info there.
Soumya
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If other applications are also updating the table using the sequence, you can also refer to the sequence nextval property in user-defined SQL.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Murali4u
Participant
Posts: 37
Joined: Sun Feb 21, 2010 12:27 pm

Post by Murali4u »

Thanks ray, other application interventions may occur, so created a user defined sql which resolves my requirement. :) But still i dont know how to use the sequence in skg stage..
Rockzz Tech
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's pretty obvious once you start playing with it.

There are three job designs that use the Surrogate Key Generator stage.
  • With no links, the Surrogate Key Generator stage creates a state file.

    With an input link, the Surrogate Key Generator stage initializes a state file or obtains initial data from a database sequence.

    With an output link, the Surrogate Key Generator stage delivers surrogate keys.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply