Max of a Timestamp

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
sainath
Premium Member
Premium Member
Posts: 138
Joined: Fri Nov 19, 2004 3:57 pm

Max of a Timestamp

Post by sainath »

Hi
I am using oci stage at input and LAST_UPDATED(Timestamp) as one of the column.
I want to capture only records whose LAST_ UPDATED > MAX(LAST_UPDATED)

I am tring to use ICONV AND OCONV functions . but i want to know if there is any other approach.
thks
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Hi,

Your post is not clear as to what you are trying to achieve. I'm thinking you want to do a incremental pull from your source table? Is that what you are trying to do?

Thanks,
Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why not just do it in the SQL?

Iconv() and Oconv() do not work with timestamps; you have to break the timestamp down into date and time components to work with these functions.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Re: Max of a Timestamp

Post by DSguru2B »

sainath wrote: LAST_ UPDATED > MAX(LAST_UPDATED)
If you use that statement, even in sql, it will always return 0 records as your retrieving records with timestamp greater than the max timestamp.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

DSguru2B wrote:If you use that statement, even in sql, it will always return 0 records as your retrieving records with timestamp greater than the max timestamp.
That's absolutely true. I thought the same. But you can store the MAX(LAST_UPDATED) from yesterday's into a job parameter and then use this job parameter in your user-defined SQL statement of the OCI stage for a incremental pull if that's what you are trying to achieve.

Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Of course. And why the fascination with User Defined SQL peoples? Nothing about using a parameter in a where clause requires user defined sql. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Sorry! My bad. Been doing a lot of user-defined SQL at the current site. So, just got carried away. :wink:

So, it can be 'Generated' or 'User-defined' SQL whichever way you prefer it.

Thanks Craig !

Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry - it's just a Pet Peeve of mine. I see way too many problems from a constant use of User-Defined SQL for no good reason. Mostly what I hear is it is 'easier' because it can be pasted from your query tool of choice. That or 'it makes it easier to read'. :roll: The perils of that approach are legion.

A comment like that would earn you a whack upside the head from me if you were under my wing. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
baglasumit21
Participant
Posts: 132
Joined: Wed Mar 01, 2006 11:12 pm
Location: Pune

Re: Max of a Timestamp

Post by baglasumit21 »

sainath wrote:Hi
I am using oci stage at input and LAST_UPDATED(Timestamp) as one of the column.
I want to capture only records whose LAST_ UPDATED > MAX(LAST_UPDATED)

I am tring to use ICONV AND OCONV functions . but i want to know if there is any other approach.
thks
Try using a sub query in the where clause of the source stage to get the records with LAST_ UPDATED > MAX(LAST_UPDATED) for eg:

where LAST_ UPDATED > (select MAX(LAST_UPDATED) from table_name where <condition for yesterdays rows>)
SMB
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Re: Max of a Timestamp

Post by DSguru2B »

baglasumit21 wrote: where LAST_ UPDATED > (select MAX(LAST_UPDATED) from table_name where <condition for yesterdays rows>)
Once again. Something like that will always retrieve 0. It should be

Code: Select all

...where LAST_UPDATED > #LastRunMaxTimeStamp#
or if your storing the Max timestamp of previous run in some other table then the subquery will be from that table, but not from the same table.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply