Pass value to parameter

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
le thuong
Premium Member
Premium Member
Posts: 76
Joined: Wed Sep 09, 2009 5:21 am

Pass value to parameter

Post by le thuong »

Hi All,



How can I do the following:



- we need to load data from an oracle source

- in this source we have a timestamp that indicates when the row was last updated/inserted

- We want to get only the rows where timestamp > lastruntime



I see a few options:

Storing lastruntime in a sql table and when running the job the next day
- fetching the lastruntime from the sql table and storing it in a parameter
- after this, executing the qry against our source like 'select * from A where timestamp > #PS_Parameters.Lastruntime#'
- Problem: How to assign a value from a resultset to a parameter?
Another approach would be to use a datastage macro. I know there is a macro like DS.Jobstarttime.
- Problem: Is there also a macro that stores lastruntime?
Yet another approach would be storing lastruntime in a sql table and when running the job the next day
- fetching the lastruntime from the sql table and storing it in a variable
- after this, executing the qry against our source like 'select * from A where timestamp > $lastruntime'
- Problem: How to store the value from a resultset to a variable?
Thanks in advance,
Thuong

best regards
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

We store that date/timestamp in another table, one dedicated to storing those "last extract dates" and then simply join the appropriate record from that table to our source query.

Otherwise, as you've noted, you need the 'overhead' of a process to fetch and store it somewhere accessible externally, like a flat file or the USERSTATUS area of a Server job. Then job control / a Sequence file could fetch that stashed value and pass it as a job parameter to the job that needs it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
JRodriguez
Premium Member
Premium Member
Posts: 425
Joined: Sat Nov 19, 2005 9:26 am
Location: New York City
Contact:

Post by JRodriguez »

Thuong

You are in the right track. We do it a bit different, we use an audit timestamp field in the target table. and use those values to determine and extracts the delta from the source.

Essentially:

- Use a sequence job, a server job, and the sourcing job
- With the server job, extract the maximum timestamp from the target and pass the timestamp value out using the job's status area
- In the parallel job, next job in the sequence, use a parameter for the timestamp that you would use in your 'select * from A where timestamp > MaxTargetTimeStamp'

Notice that the first time the target timestamp will be null, and you would need to default the value - using nvl function- to any timestamp that meet the condition
- We have an environment variable "LowDate" that we default to the company's founding date-
Julio Rodriguez
ETL Developer by choice

"Sure we have lots of reasons for being rude - But no excuses
Post Reply