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
 

 

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: 785
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 Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm


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