471,073 Members | 1,165 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Trigger Updating another table gives SQL0206N

Hello All,

I need to define a trigger for updating the multiple columns of a target table when an insert happens on a subject table.

I have written the following trigger, however, getting the following errors.

CREATE TRIGGER T_DASHBOARD
AFTER UPDATE ON REQ_GRP_REC
REFERENCING OLD_TABLE AS O
NEW_TABLE AS N
FOR EACH STATEMENT MODE DB2SQL
BEGIN ATOMIC
DECLARE CNT INT;
WHILE REQ_GRP_REC.REQ_GRP_ID = REQ_GRP.ID AND REQ_GRP_REC.PROC_STATUS = 'P' DO
SET CNT = (SELECT COUNT(REQ_GRP_REC.ID) FROM REQ_GRP, REQ_GRP_REC WHERE REQ_GRP.ID = REQ_GRP_REC.REQ_GRP_ID AND REQ_GRP_REC.PROC_STATUS = 'P');
IF (REQ_GRP_REC.STATUS_ID = '0f2bc9d1-f971-11db-9dd0-8b0bd2edbea6') THEN SET REC_PERSIS = REC_PERSIS - CNT + 2;
END IF;
IF (REQ_GRP_REC.STATUS_ID = '0f2bc9cf-f971-11db-9dd0-8b0bd2edbea6') THEN SET REC_REM_PROC = REC_REM_PROC - CNT + 2;
END IF;
END WHILE;
END@
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0206N "O.REQ_GRP_ID" is not valid in the context where it is used. LINE
NUMBER=11. SQLSTATE=42703

Please advise..

Thanks, Kiran.
Jan 5 '08 #1
0 1338

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Prince Kumar | last post: by
1 post views Thread by db2admin | last post: by
9 posts views Thread by Chico Che | last post: by
3 posts views Thread by lenygold via DBMonster.com | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.