Problem with an insert into Glocal Temporary Table

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?
Who is Participating?
momi_sabagConnect With a Mentor Commented:
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
you have an end for on line 163 but no where in the code did you start a loop
pvsbandiAuthor Commented:
Hi Momi,

   I have a "For C1 as" in the code.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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?
pvsbandiAuthor Commented:
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
pvsbandiAuthor Commented:
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!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.