Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How 2 retrieve rows 4 latest updation?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: How 2 retrieve rows 4 latest updation?
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Re: How 2 retrieve rows 4 latest updation?
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    Post subject: Re: How 2 retrieve rows 4 latest updation?
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts CICS RETRIEVE pshongal CICS 2 Thu Mar 08, 2018 9:15 am
No new posts help to replace columns by rows Vikas Maharnawar DFSORT/ICETOOL 8 Tue Mar 06, 2018 3:27 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Can we combine the rows with same key... V S Amarendra Reddy DB2 14 Fri Dec 01, 2017 10:29 pm
No new posts Conditional highlighting of rows in I... packerm CLIST & REXX 2 Thu Sep 21, 2017 6:50 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us