Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Problem with ORDER BY clause in Cursor declaration?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Problem with ORDER BY clause in Cursor declaration?
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: 788
Location: Chennai, India

PostPosted: Mon Mar 31, 2008 6:55 pm    Post subject:
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    Post subject: Reply to: Problem with ORDER BY clause in Cursor declaration
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    Post subject:
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    Post subject:
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    Post subject: Reply to: Problem with ORDER BY clause in Cursor declaration
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    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 Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am
No new posts COBOL declaration for table Poha Eater DB2 3 Mon Feb 26, 2018 6:58 pm
No new posts Preserve order in Input File pshongal DFSORT/ICETOOL 13 Thu Dec 21, 2017 4:20 pm
No new posts Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm
No new posts Having a problem FTP'ng to the MF pahiker All Other Mainframe Topics 2 Fri Nov 10, 2017 8:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us