Discussion:
Trigger with For Statement
(too old to reply)
c***@hotmail.com
2007-09-04 06:35:38 UTC
Permalink
I wanna to transfer employee data from employee to tname tables.

BEGIN
FOR SELECT firstname FROM employee
DO
INSERT INTO TNAMES VALUES (firstname);
END FOR;
END;

But it return error
"An unexpected token "firstname" was found following "IN ATOMIC FOR
SELECT".

No really understand the error message.
How to solve this ?

Thanks in Advance.
Knut Stolze
2007-09-04 08:51:45 UTC
Permalink
Post by c***@hotmail.com
I wanna to transfer employee data from employee to tname tables.
BEGIN
FOR SELECT firstname FROM employee
DO
INSERT INTO TNAMES VALUES (firstname);
END FOR;
END;
But it return error
"An unexpected token "firstname" was found following "IN ATOMIC FOR
SELECT".
No really understand the error message.
How to solve this ?
The syntax you are using is not correct. A FOR statement looks like this:

FOR cursorName AS SELECT ...

Also, you need an atomic compound statement:

BEGIN ATOMIC
FOR c AS SELECT firstname FROM employee
DO
INSERT INTO TNAMES VALUES (c.firstname);
END FOR;
END
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
c***@hotmail.com
2007-09-04 09:06:20 UTC
Permalink
Yeap! YOU ARE RIGHT!

Mr. Knut Stolze

It's working now
Save by Knut again!

c***@hotmail.com
2007-09-04 08:57:35 UTC
Permalink
Thanks for you help.

The column name is correct.
I tough I used the wrong column name
when the first time I saw this message too...

Yeap! Simply is a good idea...
Thank for advice. I almost forgot I have to simply it!
Loading...