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

Optimised Query which stops searching when a row is fetched.


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

New User


Joined: 30 Nov 2005
Posts: 19
Location: India

PostPosted: Wed Feb 15, 2006 2:57 pm
Reply with quote

Hi All,

I need a optimised query , which selects and stops when one row satisfying the given condition say for example emp_salary>10000 is met.
The query should not proceed further.
I need this query in order to reduce the DB2 cost and improve performance.

Thanks & Regards,
Yogesh.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Feb 15, 2006 8:20 pm
Reply with quote

If you use

Code:


FETCH FIRST 1 ROWS ONLY



at the end of your query should satisfy your requirement .

If this is not what you need, please explain further.

Dave
Back to top
View user's profile Send private message
yogeshbabu

New User


Joined: 30 Nov 2005
Posts: 19
Location: India

PostPosted: Thu Feb 16, 2006 1:21 pm
Reply with quote

Thanks Dave
This is what I needed.


Regards,
Yogesh.
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 RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Searching for a member but don't know... TSO/ISPF 6
Search our Forums:

Back to Top