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
 

 

Order by in EMBEDDED SQL?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Vani venkateshmurthy

New User


Joined: 20 Nov 2004
Posts: 1

PostPosted: Sat Nov 20, 2004 11:19 am    Post subject: Order by in EMBEDDED SQL?
Reply with quote

I am using an embedded SQL ( host language - COBOL) Query which has ORDER BY clause and FETCH WITH FIRST 1 ROW ONLY. When i run the query in QMF, it works fine. But it gives an error 'ORDER BY NOT PERMITTED' when the program is put for compilation. Can anyone explain why ORDER BY and FETCH WITH FIRST 1 ROW ONLY cannot be used together in Embedded SQL?
Back to top
View user's profile Send private message

janardhana Reddy

New User


Joined: 20 Oct 2004
Posts: 17
Location: Bangalore

PostPosted: Sat Nov 20, 2004 11:25 am    Post subject:
Reply with quote

You can use "optimize n rows". I forgot sybntax. You can refer book
Back to top
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Wed Dec 08, 2004 4:36 pm    Post subject: Re: ORDER BY IN EMBEDDED SQL?
Reply with quote

hi ,

i think u have to put where clause ie.

SELECT * FROM TABLE-NAME WHERE FETCH FIRST N ROWS ONLY
regards,
siva pradeep
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Wed Dec 08, 2004 5:34 pm    Post subject: Change sequence...
Reply with quote

Hi,

Both will work no problem. just use ORDER BY as a last clause that is after all other where predicates. Ok .

i.e.

select col1 from tab1 where fetch first 1 row only order by col1;
Back to top
View user's profile Send private message
richa gupta

New User


Joined: 29 Jul 2007
Posts: 8
Location: noida

PostPosted: Tue Oct 09, 2007 5:21 pm    Post subject: Reply to: ORDER BY IN EMBEDDED SQL?
Reply with quote

Hello,

I am getting same error as mentioned above by Vani. I am even getting the ORDER BY error if I comment out FETCH FIRST ONE 1 ROW ONLY. These are working fine when run in QMF. Please help.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Tue Oct 09, 2007 5:26 pm    Post subject:
Reply with quote

I know it's a dumb question, but what is the select and what is the error.....
Back to top
View user's profile Send private message
richa gupta

New User


Joined: 29 Jul 2007
Posts: 8
Location: noida

PostPosted: Tue Oct 09, 2007 5:34 pm    Post subject:
Reply with quote

I want to select rows in a cursor arranged on descending order of a field, which can be easily retrieved by ORDER BY clause.

I am getting this error:
"ORDER BY" CLAUSE NOT PERMITTED
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 cobol embedded sql MS_Developer COBOL Programming 7 Fri Oct 14, 2016 2:39 pm
No new posts SQL Order By related question Joseph K Thomas DB2 8 Fri Mar 18, 2016 12:53 pm
No new posts Null Indicator value -2 means in Embe... deepak_shrivastava DB2 2 Wed Jan 06, 2016 10:27 pm
No new posts DFSORT control statements in any order ? ronald masters DFSORT/ICETOOL 2 Tue Dec 15, 2015 11:22 pm


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