Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2014
    Posts
    294

    Unanswered: Illegal use of keyword fetch. Token with union except queryno was expected. Sqlcode=

    Hi,


    I m trying to write a query,

    INSERT INTO ERT_TY
    (z_DB_NAME,z_TABLE_NAME,z_COLUMN_NAME,S_COLUMN_TYP E,z_DATA)
    SELECT 'TRAIN12','ALBUM',
    'DEPTNAME','CHAR',DEPTNAME
    FROM TRAIN12.DEPT FETCH FIRST 5 ROWS ONLY;

    Error:
    ILLEGAL USE OF KEYWORD FETCH. TOKEN WITH UNION EXCEPT QUERYNO WAS EXPECTED. SQLCODE=-199, SQLSTATE=42601

    My db2 : version8 Z/os
    os: windows

    From the docs I got that FETCH will not work inside a subquery.

    Can some one kindly let me know , how i have to insert the first 5 rows of a table into some other table.

    please

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    sorry to make the same remark over and over again :
    there is an info center about db2
    try todo some pd/psi (problem determination problem source identification)
    and only finally : if you really don't see how - ask in forum
    or hire a skilled dba.... or at least someone that can resolve some minor problems
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Jul 2014
    Posts
    294
    Thanks for the reply. I m using some IBM data studio to connect to mainframe server & performing some activities. I tried to figure it out for long time not able to solve. hence i m asking you the experts.

  4. #4
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    not having any experience with z/db2
    I would create an sp with loop and counter : fetch 5 rows from declared cursor and do insert and leave loop
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •