IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How 2 retrieve rows 4 latest updation?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Fri Jun 08, 2007 4:18 pm
Reply with quote

Hi,

I have the requirement to fetch the record for last updation.

I am not able to fetch the record. I have tried Max function. The table contains the duplicate rows. Can you anyone tell me how to fetch the records without writing a cursor?

Time_upd is field of the table.


Thanks,

Sandy...
Back to top
View user's profile Send private message
priyamnavada

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Fri Jun 08, 2007 4:36 pm
Reply with quote

SELECT MAX(TIME_UPD)
FROM TABLE
FETCH FIRST 1 ROW ONLY;
Back to top
View user's profile Send private message
priyamnavada

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Fri Jun 08, 2007 4:38 pm
Reply with quote

sorry... i was in rush. could not able to read your question correctly. what you want? you want the records lastly updated right?
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Fri Jun 08, 2007 4:52 pm
Reply with quote

If you have a timestamp in the table you can always use that timestamp to get the latest record updated.
Back to top
View user's profile Send private message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Fri Jun 08, 2007 7:18 pm
Reply with quote

Thanks.

But yet my problem is not resolved.

MAX(TIME_UPD) will give me the unique row, but it creates the performance issue.

I need the record which is recently updated.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jun 08, 2007 7:33 pm
Reply with quote

Help-Me-Out wrote:
Thanks.

But yet my problem is not resolved.

MAX(TIME_UPD) will give me the unique row, but it creates the performance issue.

I need the record which is recently updated.


Is time_upd an indexed column, if not that would be the cause of your performance issue.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts Compare latest 2 rows of a table usin... DB2 1
Search our Forums:

Back to Top