How do I access Job Parameters from Subroutine

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

tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

I'm pretty sure that you can just access them as you would variables, e.g. if you had a job param named 'FilePath', you would use FilePath in your routine.

Hope I'm right[;)],

Tony
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Job parameters are not global parameters so they are not available to the routines called up by a server or sequence job. The way to retrieve job parameters within a routine is to either pass them in as arguments or to attach the job within the routine and use the DSGetParamInfo command to retrieve parameter values. According to the server job programming guide the DSGetParamInfo routine with the DSJ.PARAMVALUE option will return the current value of the parameter for a running job or the last job run if the job is finished.

I think the first method is better and more robust, if someone renames or removes the job parameter the job recompile will inform the user that they need to change the argument as well.

Vincent McBurney
Data Integration Services
www.intramatix.com
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

Thanks, Vincent.

Sorry to pass along bad information.

TOny
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

We are going to have to drop you back to four stars. [:D]

Vincent McBurney
Data Integration Services
www.intramatix.com
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

No problem. I'm not sure what the stars mean anyway. Whatever they mean, I probably don't deserve 5 anyway [8D]
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The stars just show aggregate posting numbers, the more the merrier. They top out at five I believe, otherwise Ray would need sixty or seventy. [:o)]

-craig
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Check out Parameter Manager for DataStage, from the folks who provide this Forum. [;)]
There's a link at the top of this screen to get you there. You can watch a (video) demo, do a tutorial, download a 30 day evaluation, determining pricing information (it's very reasonable), and even buy it!
Among other things, you can get some kind of globalization of job parameters happening, though not at run time (which is what you were after).

[Potential Conflict of Interest]
If the buyer is outside the Americas, I can supply this software and would earn a commission thereon.

All that said, there's something not right about an assertion in this thread. See my next post.

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

One of my pet peeves is folks not checking the return status of DataStage functions. In the current example, this would provide instant identification about why a parameter called FilePath could not have its value returned by DSGetParamInfo (possibilities include invalid job handle, no such parameter (misspelled/miscased), invalid value (supplied value not a pathname) and so on).


$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF

ParamName = "FilePath"

PathName = DSGetParamInfo(hJob, ParamName, DSJ.PARAMVALUE)
Begin Case
Case PathName = DSJ.BADHANDLE
Msg = "Job not attached (DSGetParamValue)."
Case PathName = DSJ.BADPARAM
Msg = "Parameter " : Quote(ParamName) : " not found in job."
* ... and so on
End Case
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Raggid

Vincent is correct. You need to pass it as an argument. If I am reading your message correctly the problem may be that a parameter name should not have spaces in it. If you have a parameter named file path then change it to FilePath. Next call your routine like this MyRoutine(FilePath) in a derivation. If you are calling it from job control then the syntax is a little different.

Thanks Kim.


Kim Duke
DwNav - ETL Navigator
www.Duke-Consulting.com
alex
Participant
Posts: 7
Joined: Sat Jun 07, 2003 8:24 am
Contact:

Post by alex »

quote:Originally posted by raggid
[br]I have a lot of parameters defined and it would be messy to have to redefine then in the subroutine I am using.

How do I access the values in already defined job parameters?

Thanks in advance,
Raggy
alex
Participant
Posts: 7
Joined: Sat Jun 07, 2003 8:24 am
Contact:

Post by alex »

when you call routine, you have to pass job parameters to routine parameter. Then you can access job parameter.
quote:Originally posted by raggid
[br]I have a lot of parameters defined and it would be messy to have to redefine then in the subroutine I am using.

How do I access the values in already defined job parameters?

Thanks in advance,
Raggy
Post Reply