Page 1 of 1

Select value into Job Parametr

Posted: Mon Jul 11, 2005 5:31 am
by snassimr
Hi !

I need to set Job Parametr to value from database

How i can do it ?

Posted: Mon Jul 11, 2005 5:36 am
by ArndW
snassimr,

since job parameters cannot be changed within the job they are used in you will need an indirect approach. Write a DataStage job to read the database values and write them to a hash file or sequential file. Then write a short function in Uv/BASIC to read this value and return it to the caller. Then write a DataStage sequence which calls this routine activity and gets the parameter value to pass to a DataStage job.

Posted: Mon Jul 11, 2005 5:36 am
by Sainath.Srinivasan
Read the value from the database
Set it in a variable
Pass it to the job via the parameters - via api if from OS, via job control if from DS Batches, via job routines if from sequencer.

Posted: Mon Jul 11, 2005 5:47 am
by snassimr
May be you can post the code extracting non-key field from hash file

Thank in advance

Posted: Mon Jul 11, 2005 6:19 am
by ArndW
snassimr,

no code for this from me, although I think a good search will pick up some. You need to use the BASIC commands "OPEN" to open the hash file, and "READ" to read a record.

Posted: Mon Jul 11, 2005 6:31 am
by ray.wurlod
SELECT the value into a text file, use an Execute Command activity to read the value from that file.

Posted: Mon Jul 11, 2005 10:52 am
by kduke
May be you can post the code extracting non-key field from hash file
Why you want to do this? The purpose of a hash file is to use keys. If you are reading parameter values then the key should be the parameter name. The value should be field 1.

Code: Select all

ParamName = Arg1
open "MyParamValues" to ParamHashFile else stop
read ParamRec from ParamHashFile, ParamName else
   ParamRec = ''
end
ParamValue = ParamRec<1>
Ans = ParamValue

Posted: Mon Jul 11, 2005 3:57 pm
by ray.wurlod
STOP statement in Routine is bad practice. Routines should always return. Prefer something like

Code: Select all

ParamName = Arg1
ParamRec = ""
OpenPath "C:\users\mydir\MyParamValues" To ParamHashedFile
Then
   Read ParamRec From ParamHashedFile, ParamName
   Else
      ParamRec = ""
      Call DSLogWarn("Value for " : ParamName : " not found.", "Loading")
   End
End
Ans = ParamRec<1>

Posted: Tue Jul 12, 2005 3:59 am
by kerensho
Hello,

You can read the value from the DB into a transformer in which you can use a StageVariable to call the UtilityRunJob routine like that:

UtilityRunJob("JobName", "JobParam1=value1|Jobparam2=value2....","RowsLimit","WarningsLimit")

You need to pass all of the jobs parameters, though.
this is also good for a loop (when you want to run a job for each record you read from a file and transfer parameters from the same record).

hope it helps'
Keren

Posted: Tue Jul 12, 2005 5:34 am
by roy
Hi,
Just wanted to state that if you use the option of the routine givven to run DS jobs verify no passwords will be written to the logs.

IHTH,