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

Problem with ORDER BY clause in Cursor declaration?


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

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Mon Mar 31, 2008 6:50 pm
Reply with quote

I am getting compilation error for ORDER BY clause in this Cursor.Please tell me why i am getting this error

EXEC SQL DECLARE IMAGE_TOUR_CSR2 CURSOR FOR
SELECT IMG_NME,
IMG_DTE,
IMG_FLAG
FROM IMG_TABLE
WHERE IMG_FLAG = 'S' OR 'R'
ORDER BY IMG_FLAG ,IMG_DTE
END-EXEC.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Mon Mar 31, 2008 6:55 pm
Reply with quote

What is the error code and its description?
Back to top
View user's profile Send private message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Mon Mar 31, 2008 7:01 pm
Reply with quote

the compilation error and description for the above cursor problem is,

DB2 SQL PRECOMPILER MESSAGES
DSNH199I E DSNHPARS LINE 115 COL 20 INVALID KEYWORD "ORDER"; VALID SYMBOLS ARE: < > = <> <= !< !> != >= ¬< ¬> ¬= IN NOT .
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Mon Mar 31, 2008 7:12 pm
Reply with quote

i think that the WHERE clause should be

WHERE IMG_FLAG = 'S' OR IMG_FLAG = 'R'

instead of WHERE IMG_FLAG = 'S' OR 'R'
Back to top
View user's profile Send private message
Suresh Ponnusamy

Active User


Joined: 22 Feb 2008
Posts: 107
Location: New York

PostPosted: Mon Mar 31, 2008 7:16 pm
Reply with quote

Please try this

EXEC SQL DECLARE IMAGE_TOUR_CSR2 CURSOR FOR
SELECT IMG_NME,
IMG_DTE,
IMG_FLAG
FROM IMG_TABLE
WHERE IMG_FLAG = 'S'
OR IMG_FLAG = 'R'
ORDER BY IMG_FLAG ,IMG_DTE
END-EXEC.

(OR)


EXEC SQL DECLARE IMAGE_TOUR_CSR2 CURSOR FOR
SELECT IMG_NME,
IMG_DTE,
IMG_FLAG
FROM IMG_TABLE
WHERE IMG_FLAG IN ( 'S','R')
ORDER BY IMG_FLAG ,IMG_DTE
END-EXEC.
Back to top
View user's profile Send private message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Mon Mar 31, 2008 7:21 pm
Reply with quote

Thanks Gautam....Now it is working fine with CNTL_FLAG = 'E' OR CNTL_FLAG = 'H' .
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Rotate partition-logical & physic... DB2 0
No new posts To search DB2 table based on Conditio... DB2 1
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
Search our Forums:

Back to Top