initializing parameter, inside a transformer stage

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
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

initializing parameter, inside a transformer stage

Post by talk2shaanc »

hi Guys,
My requirement is something like reading a sequential file with header and trailer then loading data into a oracle DB with some business logic in b/w along with a date field which will be read from the header. Then using the loaded records (Not all the colmns) to create an outbound file. For this I need to specify header date in my SQL query to fetch only those data which where loaded. Is it possible to initialize a job parameter or Environment variable inside the transformer after reading the header? I think its not possible, as parameter initialization takes place before running the job and if you use DSSETPARMS in current job to initialize a parameter in the same job, it will give you error=-1(invalid job handle). Taking max date in SQL is not a good logic, as it would fetch previous day data, if current day load is zero.Can anyone suggest a way around.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You can make this a user defined query and use the parameter in a where clause like

select
from
where UPDATE_TS > to_date('#StartDate#')

You can calculate this date in the job before this. You will need to store this date in a hash file or sequential file and read it back to feed it into this job. You may need to write a batch job to do this.
Mamu Kim
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
if I understood you correctly :roll: :
you can split the job into 2 parts 1 job setting its own user status to hold the date value and the other receiving it as a parameter.
wrap both in a sequence job.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

That is correct.
Mamu Kim
clshore
Charter Member
Charter Member
Posts: 115
Joined: Tue Oct 21, 2003 11:45 am

Post by clshore »

You didn't specify what database. One way I have used with Oracle OCI stage, is to dynamically create the Sql statement into a named flat file, then specify that file as the source of the query in the OCI stage.

ex)
Derive the date value into stage variable dateSvar. Write the query into flat file Date.sql, formatted with a single varchar(255) column, no quotes, no delimters, etc.:

"select foo from bar where goo_date = '": dateSvar :"'"

Note the single and double quotes enclosing the date literal.

Then reference file Date.sql in the OCI query that fetches the dataset you want.

A kludge, yes, but it offers quite bit of flexibility, plus the generated Sql statement is available for debugging, logging, etc.

Carter
clshore
Charter Member
Charter Member
Posts: 115
Joined: Tue Oct 21, 2003 11:45 am

Post by clshore »

Oops, forgot to say that you should document such kludges *very* thoroughly.

Carter
Post Reply