Getting Max Row From DB2 To Be Used DownStream
Moderators: chulett, rschirm, roy
Getting Max Row From DB2 To Be Used DownStream
I want to get the max(row_id)+1 from a db2 table then use this value as a parameter to pass into my surrogate stage.. what is the best way to implement this?
I can create the DB2 job first to get the result...but then I want to use that result downstream, how would I pass it to be used downstream?
Thanks
dtatem
I can create the DB2 job first to get the result...but then I want to use that result downstream, how would I pass it to be used downstream?
Thanks
dtatem
USER STATUS is not present in parallel jobs.
For a parallel job. You can load the value into a flat file and then use execute command stage to cat the value and pass it as a parameter value to your next job, via job sequence.
For a parallel job. You can load the value into a flat file and then use execute command stage to cat the value and pass it as a parameter value to your next job, via job sequence.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Getting Max Row From DB2 To Be Used DownStream
Thanks, seems kinda complex can you provide some additional information? Kinda new at thisDSguru2B wrote:USER STATUS is not present in parallel jobs.
For a parallel job. You can load the value into a flat file and then use execute command stage to cat the value and pass it as a parameter value to your next job, via job sequence.
dtatem
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Rubbish! A parallel job can certainly be used. Put a DB2 stage feeding a reference link to a Lookup stage, and execute the query in the DB2 stage.
The trick is to make sure that the reference input to the Lookup stage uses Entire partitioning, so that the same initial value is available on all partitions.
Upstream use a Column Generator stage to generate the constant value 'X'. Use this as the lookup key.
Downstream, in a Transformer stage, you increment as required; you will need an expression based upon the partition number and partition count to guarantee uniqueness. Search the forum or Vincent's blogs; the expression has been given a number of times before.
Code: Select all
SELECT 'X', MAX(surrkey) + 1 FROM tablename
Upstream use a Column Generator stage to generate the constant value 'X'. Use this as the lookup key.
Downstream, in a Transformer stage, you increment as required; you will need an expression based upon the partition number and partition count to guarantee uniqueness. Search the forum or Vincent's blogs; the expression has been given a number of times before.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Getting Max Row From DB2 To Be Used DownStream
ray.wurlod wrote:Rubbish! A parallel job can certainly be used. Put a DB2 stage feeding a reference link to a Lookup stage, and execute the query in the DB2 stage.Code: Select all
SELECT 'X', MAX(surrkey) + 1 FROM ...[/quote] with the lookup stage, what am I joining on? I am not sure on this...if you can mock up a dsx and email it to me that would be great dtatem
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
....and who said it cant be. The job type argument was based on specifically using USER STATUS. Any other method, including the one you advised, has no relation to the "USER STATUS with Parallel Job" discussion.ray.wurlod wrote:Rubbish! A parallel job can certainly be used.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Nothing to stop you using the user status area in a parallel job. Though you will need to create a parallel routine that invokes DSSetUserStatus() - the one from the C-callable API.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Or - I assume - use a BASIC Transformer in the PX job, with all the caveats that brings to the table. It's not that Parallel jobs "don't have a user status area" - they do. It's just that it is not quite as simple to get to in a Parallel job as it is in Server. ![Wink :wink:](./images/smilies/icon_wink.gif)
![Wink :wink:](./images/smilies/icon_wink.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Ray:
Getting back to your reply on "Rubbish! A parallel job can certainly be used. Put a DB2 stage feeding a reference link to a Lookup stage, and execute the query in the DB2 stage. Code: SELECT 'X', MAX(surrkey) + 1 F ..."
If I understand what you are referring to, I use a sequential File going into a lookup stage with the DB2 statement you mentioned. In the sequential File I Have one column 'X' joining to the DB2 stage which also have a colum 'X'
Is this is what you mean?
thanks,
dtatem
Getting back to your reply on "Rubbish! A parallel job can certainly be used. Put a DB2 stage feeding a reference link to a Lookup stage, and execute the query in the DB2 stage. Code: SELECT 'X', MAX(surrkey) + 1 F ..."
If I understand what you are referring to, I use a sequential File going into a lookup stage with the DB2 statement you mentioned. In the sequential File I Have one column 'X' joining to the DB2 stage which also have a colum 'X'
Is this is what you mean?
thanks,
dtatem
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Not quite.
What I mean is a new column, generated in a Column Generator stage (that is, not in the file itself). The column name can be anything you like; the value in it must be 'X' for every row.
What I mean is a new column, generated in a Column Generator stage (that is, not in the file itself). The column name can be anything you like; the value in it must be 'X' for every row.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.