Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search 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
Author Message
babu_hi

Active User


Joined: 11 Apr 2006
Posts: 50

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
References
PostPosted: Mon Mar 31, 2008 6:50 pm    Post subject: Re: Problem with ORDER BY clause in Cursor declaration? Reply with quote

Gnanas SNG

Senior Member


Joined: 06 Sep 2007
Posts: 370
Location: 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

Active User


Joined: 11 Apr 2006
Posts: 50

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: 100
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

New User


Joined: 22 Feb 2008
Posts: 8
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

Active User


Joined: 11 Apr 2006
Posts: 50

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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1