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

how to use index in cursor ?


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

New User


Joined: 09 Feb 2007
Posts: 11
Location: Pune

PostPosted: Tue Mar 17, 2009 4:01 pm
Reply with quote

how to use index in cursor? Please send me the sample code for the same.
Back to top
View user's profile Send private message
anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Tue Mar 17, 2009 4:23 pm
Reply with quote

ritesh pandey,
An index is used to retrieve the data efficiently
Code:

EXEC SQL                                           
SELECT                                             
FIELD                                           
INTO                                               
:WS-FIELD                               
FROM TABLE_NAME                                   
WHERE INDEX  = :WS-INDEX     
END-EXEC                                           
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Mar 17, 2009 5:51 pm
Reply with quote

It is not you who use an index, it is DB2.
According to the WHERE clause, the ORDER BY clause, and other stuff, DB2 will decide to use - or not to use - an index.

If you want to know what will be used, you have to ask DB2 for some EXPLAINations...
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 Cobol file using index COBOL Programming 2
No new posts DL/I status code AK for GU call using... IMS DB/DC 1
No new posts Add column to existing records using ... JCL & VSAM 2
No new posts choice of clustering index DB2 3
No new posts Secondary index error while loading d... IMS DB/DC 2
Search our Forums:

Back to Top