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
 

 

Query Problem : NESTING TABLE

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

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Mon Sep 29, 2008 12:46 pm    Post subject: Query Problem : NESTING TABLE
Reply with quote

Hi,

This is a testing Query, if this works i got to make a bigger query. This is not working itself. I think its correct.

This table contains only this 3 columns

Code:
SELECT * FROM       
(SELECT ID,"NAME",DEPTNO           
FROM SHANDB.EMPLOYEE               
ORDER BY ID DESC                   
FETCH FIRST 3 ROWS ONLY) AS RESULTES


Errors :
I checked for the syntax errors in ISQL
Code:
SQL009: Invalid TOKEN detected while processing a     
        SELECT statement.                             
        Expecting one of  UNION  ORDER  FOR  OPTIMIZE 


Sometimes the query works after this also, so i executed it

When executed this is the error i got
Code:
 DSNT408I SQLCODE = -199, ERROR:  ILLEGAL USE OF KEYWORD ORDER.  TOKEN
          UNION EXCEPT WAS EXPECTED                                   
 DSNT418I SQLSTATE   = 42601 SQLSTATE RETURN CODE                     
 DSNT415I SQLERRP    = DSNHPARS SQL PROCEDURE DETECTING ERROR         
 DSNT416I SQLERRD    = 506  0  0  -1  66  0 SQL DIAGNOSTIC INFORMATION
 DSNT416I SQLERRD    = X'000001FA'  X'00000000'  X'00000000'           
          X'FFFFFFFF'  X'00000042'  X'00000000' SQL DIAGNOSTIC         
          INFORMATION                                                 
 BPA0012E: DB2 SQL/DDL ERROR HAS OCCURRED - ROLLBACK ISSUED.           
RETCODE =     8                                                       


Please HELP me
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 Sep 29, 2008 11:46 pm    Post subject:
Reply with quote

Hi

Please check your DB2 version. Only DB2 9 supports ORDER BY and FETCH FIRST <N> ROWS ONLY in the Subquery, not the earlier versions.

Please refer
http://www.db2portal.com/2007/04/order-by-and-fetch-first-in-subselects.html
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 Data replication from multiple Db2 ta... kishpra DB2 5 Mon Mar 27, 2017 9:58 pm
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm


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