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

Cursor in DB2.


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

New User


Joined: 06 Sep 2013
Posts: 15
Location: Cube

PostPosted: Tue Jul 15, 2014 12:04 pm
Reply with quote

Am trying to bind a package in IBM DB2 (mainframe) involving a SENSITIVE STATIC SCROLL cursor with ORDER BY and FOR UPDATE clause in it , but it fails with SQLCODE -243 whereas the same bind sucessfull without the ORDER BY clause. Any idea what could be the reason for this? We are using DB2 v10.0.

Output of the BIND is

Code:
DSNX200I -T1G2 BIND SQL ERROR

USING AIDABPTU AUTHORITY

PLAN=(NOT APPLICABLE)

DBRM=DBAMAGIX

STATEMENT=4586

SQLCODE=-243

SQLSTATE=36001

TOKENS=

CSECT NAME=DSNXEPP

RDS CODE=-190

SQL Statement causing this issue:

EXEC SQL

DECLARE CAGIX723 SENSITIVE STATIC SCROLL CURSOR FOR

SELECT PART_ID

,COLUMN1
,COLUMN2
,COLUMN3
,.
,.
,.
,COLUMNn
WHERE column1 = :host-var1
and column2 = ;host-var2
ORDER BY COLUMN2, COLUMN3 ,COLUMN4
FOR UPDATE
END-EXEC.
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Tue Jul 15, 2014 2:25 pm
Reply with quote

Hi,

You cant use FOR UPDATE and ORDER BY simultaneously.

When you mention ORDER BY clause resultant table of query is a read only table and you can not use FOR UPDATE clause for that table

Regards,
Chandan
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Tue Jul 15, 2014 2:35 pm
Reply with quote

Below is the link for similar topic discussed on forum

http://ibmmainframes.com/about45670.html

Also below what DB2 manual says for V10

Quote:
The ORDER BY clause cannot be used in an outermost fullselect that contains a FOR UPDATE clause

I also have same doubt as per link why you need order by for performing updates?
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 Is SQLCODE -811 possible while fetchi... DB2 1
No new posts Restart logic by using cursor name in... DB2 1
No new posts Seeking Resolution for SQKCODE -991 o... DB2 2
No new posts Multiple rows within Cursor when Coun... DB2 14
No new posts Dynamic cursor name in Cobol program COBOL Programming 1
Search our Forums:

Back to Top