Increment of row number

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
devanars
Premium Member
Premium Member
Posts: 99
Joined: Thu Nov 30, 2006 6:25 pm

Increment of row number

Post by devanars »

Hi, First job is inserting 10 records in one table with increment of Temp_Id like 1,2,3.......10
The second job need to insert 20 more records in the same table with increment of Temp_Id by taking the last value of the first insert like 11,12,......30

Appreciate your help on this.Thanks
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

There are a couple of ways of accomplishing this.

1. Create a sequence/trigger within your database to automatically assign a value to the Temp_id when the values are loaded; or

2. Use a bit a sql code to retrieve the current max(temp_id) from the that table. Pass this value to a surrogate key generator stage and use that to create your temp_id, using the max(temp_id) as your starting point (pass it in as a parameter).
Last edited by ShaneMuir on Fri May 22, 2009 7:59 am, edited 1 time in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

OK... how are you generating this "temp_id" value currently? Investigate the use of the Surrogate Key Generator stage and the use of a "state file", that's the "official" way to handle stuff like this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
devanars
Premium Member
Premium Member
Posts: 99
Joined: Thu Nov 30, 2006 6:25 pm

Post by devanars »

Earlier i did this sequence number by using stage variable in transformer.but now i need to take max value of that and need to process it again to another job/table.
devanars
Premium Member
Premium Member
Posts: 99
Joined: Thu Nov 30, 2006 6:25 pm

Post by devanars »

Earlier i did this sequence number by using stage variable in transformer.but now i need to take max value of that and need to process it again to another job/table.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Can you not do something like Shane posted as #2 above - retrieve the max value using SQL and pass that as a job parameter that is the starting value for the job run.
-craig

"You can never have too many knives" -- Logan Nine Fingers
devanars
Premium Member
Premium Member
Posts: 99
Joined: Thu Nov 30, 2006 6:25 pm

Post by devanars »

I am getting an eroor while trying to get max(col) through sql in source stage. is there any way to get the max value

Error executing View Data command:##E IIS-DSEE-TOPK-00007 15:19:17(010) <_PEEK_IDENT_> Input dataset does not have field:
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

Are you able to get any value when you execute the same query in toad or sqlplus ??
Nag
devanars
Premium Member
Premium Member
Posts: 99
Joined: Thu Nov 30, 2006 6:25 pm

Post by devanars »

Yes i am getting the max val of that col when executed but not in datastage source stage. server stage is working fine only the issue with parallel oralce stage.
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Using the parallel extender you cannot get a serial number. You need to use the database sequence features.

Regards
Sreeni
Post Reply