DS390: Getting MAX Surrogate value into transform

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
tomengers
Participant
Posts: 167
Joined: Tue Nov 19, 2002 12:20 pm
Location: Key West

DS390: Getting MAX Surrogate value into transform

Post by tomengers »

Hi Folks ...

Can anyone suggest an elegant way to get a MAX surrogate value into a DS390 transform (to be used as an assignment start point)? Were this a server job I would use the built-in key management function. I'm presently doing a MAX to obtain the highest value and then using a JOIN to connect this value to each incoming add transaction which is clumsy and inelegant, since only the first incoming row value is actually used. It works, but I really don't like it.

... tom
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Key West, really Tom, is life rough? :lol:

I don't know DS/390, but what about a job parameter? Initially fetch the max value and then feed into the next job as a parameter?
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Hi Tom,

I've used a GDG dataset as a parameter file for surrogate key management. Job reads gen 0 to get the starting value and writes the last value to gen +1 at the end. Use a stage variable in the transformer to increment (i.e. NextVal = ParmVal + NextVal + 1). NextVal is initialized to 0, and remember that ParmVal is constant throughout the job execution. In case of an ABEND, you still have the original gen 0 for restart purposes.

Mike
tomengers
Participant
Posts: 167
Joined: Tue Nov 19, 2002 12:20 pm
Location: Key West

Post by tomengers »

Ken ... ah yes ... consulting in 'Paradise' is as good as it gets (but the downside is that none of my clients are here). Thanks for the tip - looks like you and Mike are on the same page.

Mike ... GDG is great idea. That would work for me! But I need a little help here: once I get it, how do I drive the GDG "next val" into a parameter for the next step?

... tks guys

... tom
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Tom,

It's been a while since I've done 390 work, but from memory:

1) Go to the Parameters tab on the Job Properties page .
2) Put in a DD name (e.g. JOBPARM)
3) Put in the GDG dataset name (e.g. MY.GDG(0))
4) Fill in the parameter names in the grid. These parameters should be available to use in the expression editor.

Mike
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Tom,

Sorry, I just reread your post and it looks like you might have actually been asking about how to write the final value back out.

Just create an extra flat file as an output from your transformer. Put in a constraint so that it only gets written to when you hit an end of file condition on your input. Assign it a DD name (e.g. NEWPARM). Assign it a Dataset name (e.g. MY.GDG(+1)). Load column metadata so that it matches the column metadata on the Parameters Page of Job Properties. Then simply map your NextVal stage variable into the appropriate target column.

Mike
tomengers
Participant
Posts: 167
Joined: Tue Nov 19, 2002 12:20 pm
Location: Key West

Post by tomengers »

Mike ...

Super! And thanks ... your next-to-last post was the one I needed - didn't realize you could throw DD names into the parameter grid. Really appreciate the help. :D

... tom
Post Reply