473,245 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 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 1467

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

Similar topics

0
by: Sean Utt | last post by:
Table "grps" Column | Type | Modifiers -------------+-----------------------------+-------------------------------- --------------------- grpsid ...
1
by: Rebecca Lovelace | last post by:
I have a trigger on a table. I am trying to dynamically log the changed fields on the table to another table, so I am iterating through the bits in COLUMNS_UPDATED() to find what's changed, and...
14
by: John | last post by:
Hi all, I am doing the change from having worked in Oracle for a long time to MS SQL server and am frustrated with a couple of simple SQL stmt's. Or at least they have always been easy. The...
3
by: Prince Kumar | last post by:
Hi All, I am trying to a get a trigger retrieved from Oracle to work on DB2 UDB 8.1. I am getting the following error when trying to create the trigger. How would I resolve this? create table...
1
by: db2admin | last post by:
Hello, I lack knowledge about triggers. I have created trigger on table A Table A ------------------------------------------------- ID INTEGER CASEID ...
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
2
by: graju80 | last post by:
Hey Gurus..I am trying to figures out where my syntax is incorrect in the following SQL to to create an after insert trigger... I am getting SQL0206N "INSERTROW.MF_USERID" is not valid in the...
9
by: Chico Che | last post by:
Have a table that has following fields (pkid, field1, field2, field3, field4). I need to create a trigger that will insert a row into another table with the pkid column that was updated. Any help...
3
by: lenygold via DBMonster.com | last post by:
Hi everybody! I have an INSERT stattement like this: insert into ELIGIBLE_PAY select from ELIGIBLE_PAY_B where cust_id = 999999; after insert i would like to delete row from source table by...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.