Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

cursor with hold having joins and subquery.. is it possible?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
tsantosh

New User


Joined: 03 Aug 2006
Posts: 8

PostPosted: Thu Jun 28, 2007 6:46 am    Post subject: cursor with hold having joins and subquery.. is it possible?
Reply with quote

Can I declare a cursor with hold for the following query

SELECT DISTINCT S.STOV_ID, S.SPCL_TKT_CD
FROM QUAL.STOV P, QUAL.STOV_SPCL S
WHERE P.STOV_ID = S.STOV_ID
AND S.CANC_DT = '99/99/9999'
AND S.ETA_IND = 'Y'
AND S.PRI_CD = 'P'
AND P.CANC_DT = '99/99/9999'
AND S.STOV_ID NOT IN
( SELECT SPC.STOV_ID
FROM QUAL.STOV_PDRF_CONTR SPC
WHERE SPC.CANC_DT = '99/99/9999'
AND SPC.CONTR_TYP_CD = 'H'
AND SPC.TKT_NBR BETWEEN 01000 AND 60000
AND S.STOV_ID = SPC.STOV_ID)

I need to update data only in table STOV_SPCL ..
Back to top
View user's profile Send private message

Johnson_Jiang

New User


Joined: 05 Apr 2007
Posts: 11
Location: China,ShenZhen

PostPosted: Thu Jun 28, 2007 8:09 am    Post subject: Re: cursor with hold having joins and subquery.. is it possi
Reply with quote

Quote:

Can I declare a cursor with hold for the following query

Code:
SELECT DISTINCT S.STOV_ID, S.SPCL_TKT_CD
FROM QUAL.STOV P, QUAL.STOV_SPCL S
WHERE P.STOV_ID = S.STOV_ID
AND S.CANC_DT = '99/99/9999'
AND S.ETA_IND = 'Y'
AND S.PRI_CD = 'P'
AND P.CANC_DT = '99/99/9999'
AND S.STOV_ID NOT IN
( SELECT SPC.STOV_ID
FROM QUAL.STOV_PDRF_CONTR SPC
WHERE SPC.CANC_DT = '99/99/9999'
AND SPC.CONTR_TYP_CD = 'H'
AND SPC.TKT_NBR BETWEEN 01000 AND 60000
AND S.STOV_ID = SPC.STOV_ID)

I need to update data only in table STOV_SPCL ..


I think it doesn't work! In the sub SQL, you should also involve the table QUAL.STOV_SPCL, the join condition is incorrect.
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Thu Jun 28, 2007 9:37 am    Post subject:
Reply with quote

Hello,

I didnt have a chance to look at the syntax of the sql query. The bottom line is, if you have JOIN in the cursor then it happens to be READ ONLY CURSOR. There are some more restrictions like, if a query in cursor contains GROUP BY or ORDER BY or column/aggregate fucntions it happens to be READ ONLY. please refer to manual for more information.
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 Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts How LOAD PROGRAM and LOAD on HOLD is ... pkmurali CICS 4 Tue May 03, 2016 6:26 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us