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 Loading data to table gives wrong for... Raghu navaikulam DB2 18 Thu Jul 13, 2017 2:11 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts unload data from table with lob columns farhad_evan DB2 1 Sat Apr 22, 2017 1:32 pm
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm


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