Problem with an insert into Glocal Temporary Table

Posted on 2011-10-14
Last Modified: 2012-06-27
Hi ,

   Attaching my stored procedure where i have the problem.
   The error it is throwing is :
[IBM][CLI Driver][DB2/AIX64] SQL0104N  An unexpected token "END FOR" was found following "GENERAL_NEGLECT);   ".  Expected tokens may include:  "<psm_statement>".  LINE NUMBER=163.  SQLSTATE=42601

Open in new window

Can someone kindly help me understand what's wrong?
Question by:pvsbandi
    LVL 37

    Expert Comment

    you have an end for on line 163 but no where in the code did you start a loop

    Author Comment

    Hi Momi,

       I have a "For C1 as" in the code.
    LVL 37

    Expert Comment

    i never saw that syntax style before
    are you sure its valid?
    what happens if you remove the insert statement from the end of the loop?

    Author Comment

    I get this error, when i removed the insert and  p2 sections.

    SQL0104N  An unexpected token "FOR C1 AS  SELECT          TB_SCREEN" was found following ") WITH REPLACE;  ".  Expected tokens may include:  "<psm_statement>".  LINE NUMBER=167.  SQLSTATE=42601
    LVL 37

    Accepted Solution

    i would try to make as simple as possible
    change you query of the loop to something like select * from sysibm.sysdummy1
    then in the loop remove all the statements

    once that works, revert back to your original query
    once that works start adding the if statements in the loop

    until you find what breaks it

    Author Closing Comment

    Thanks so much! that really helped.
      I forgot a END IF in the code and it was hard to find.
    Your advise worked greatly.
    Thanks again!

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
    Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now