Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

Lawan

Technical User
May 8, 2002
1
US
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.
 
Hi Lawan,

Create a routine ReadParameter like :

Code:
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 :

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.
 
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!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top