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 Conditional highlighting of rows in I... packerm CLIST & REXX 2 Thu Sep 21, 2017 6:50 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm

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