IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Query Problem : NESTING TABLE


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Mon Sep 29, 2008 12:46 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts RC query -Time column CA Products 3
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top