Comparing with max timestamp

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
hema177
Participant
Posts: 19
Joined: Fri Apr 07, 2006 12:29 pm
Location: Edinburgh

Comparing with max timestamp

Post by hema177 »

Hi,

I am trying to do incremental loads. I need to select the max timestamp from the target table, compare it with a timestamp value in the Source table and select all rows which are greater than the max timestamp.

I am trying to use the lookup stage in parallel to do this but need some suggestions on how to go about the same.

Thanks in advance,

Hema
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If both the tables are in the same schema then you can do it in one database stage itself.
Something like

Code: Select all

select * from TABLE1 
where timestampColumn > (select Max(Timestamp) from TABLE2)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
hema177
Participant
Posts: 19
Joined: Fri Apr 07, 2006 12:29 pm
Location: Edinburgh

Post by hema177 »

DSguru2B wrote:If both the tables are in the same schema then you can do it in one database stage itself.
Something like

Code: Select all

select * from TABLE1 
where timestampColumn > (select Max(Timestamp) from TABLE2)
Thanks for the response. Actually, I am trying to do incremental loads from an audit table which has thousands of rows added to it everyday. So if I run the job today it should only pick up those rows which were added after yesterday's load. So the logic is timestampcol > max(yesterday's timestamps). I can't figure out how to incorporate this into Datastage. Any ideas?

One more thing, I want to run this query from a user defined sql file. But that option doesnt seem to work in datastage. Is this a bug ?

Cheers

Hema
thumsup9
Charter Member
Charter Member
Posts: 168
Joined: Fri Feb 18, 2005 11:29 am

Post by thumsup9 »

select * from TABLE1
where timestampColumn > #PullDate#

and you can always pass the current date to your parameter.
thumsup9
Charter Member
Charter Member
Posts: 168
Joined: Fri Feb 18, 2005 11:29 am

Post by thumsup9 »

thumsup9 wrote:select * from TABLE1
where timestampColumn > #PullDate#

and you can always pass the current date to your parameter.
parameter value should be currentdate-1
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Which database and which database stage are you using?

You could certainly use an SQL file from a shell script executed from an Execute Command activity in a job sequence.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

What stopping you from using the Userdefined SQL query, and updating the Audit table after the job.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply