×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DataStage: How can I assign value into Job Parameter?
2

DataStage: How can I assign value into Job Parameter?

DataStage: How can I assign value into Job Parameter?

(OP)
As I don't want to hard code the Job Parameter into the DataStage Job, is it possible to read some parameter value from the configuration file (for example, config.ini), then assign those values into Job Parameter? If so, could somebody give me a sample to do that please?

In case, the above scenario can be done, is it possible that I write it as a routine? But if I write it as a routine, how can I refer to DataStage Job's Job Parameter? Please give me some sample code.

Thanks a lot.

RE: DataStage: How can I assign value into Job Parameter?

2
Hi Lawan,

Create a routine ReadParameter like :


FUNCTION ReadParameter(ParameterName, DefaultValue,ConfigFile)

*
* Function : ReadParameter - Read parameter value from configuration file
* Arg      : ParameterName  (default=JOB_PARAMETER)
*         DefaultValue   (default='')
*            Config file    (default=@PATH/config.ini)
* Return   : Parameter value from config file
*

  If ParameterName = "" Then ParameterName = "JOB_PARAMETER"
  If ConfigFile = "" Then ConfigFile = @PATH:"/config.ini"

  ParameterValue = DefaultValue

  OpenSeq ConfigFile To fCfg
    Else Call DSLogFatal("Error opening file ":ConfigFile, "ReadParameter")

  Loop
  While ReadSeq Line From fCfg
    If Trim(Field(Line,'=',1)) = ParameterName
    Then
      ParameterValue = Trim(Field(Line,'=',2))
      Exit
    End
  Repeat

  CloseSeq fCfg

  Ans = ParameterValue

RETURN(Ans)


You can define parameters values in you config file (/ds/config?ini as an example) in the form :

  Parameter = Value
  InputFile = /ds/file.dat

To set the value of parameter 'InputFile', in your Job code :


DEFFUN ReadParameter(ParameterName, DefafaultValue, ConfigFile) CALLING "DSU.ReadParameter"

PrmName    = 'InputFile'
PrmConfig  = '/ds/config.ini'

PrmDefault = DSGetParamInfo(DSJ.ME, PrmName, DSJ.PARAMDEFAULT)
PrmValue   = ReadParameter(PrmName, PrmDefault, PrmConfig)
ErrCode    = DSSetParam(DSJ.ME, PrmName, PrmValue)

Call DSLogInfo("InputFile is ":PrmValue, DSJobName)

Jean Pierre.

RE: DataStage: How can I assign value into Job Parameter?

hi there!

this is a rather different approach. it doesnt read from a config file, though.
what we did was create batch files wherein repeatedly-used parameters were assigned to variables and those variables in turn were passed as parameters during the run job statement. The paramaters of course had to be defined in the Designer [Edit-Job Property-Parameter]

sample code:
set Db=dbname
set Usr=usrnme
set Pass=paswrd

dsjob -run Job1 -param DbName=%Db% -param DbUid=%Usr% -param DbPass=%Pass%
dsjob -run Job2 -param DbName=%Db% -param DbUid=%Usr% -param DbPass=%Pass%
dsjob -run JobN -param DbName=%Db% -param DbUid=%Usr% -param DbPass=%Pass%

hope this helps!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close