473,322 Members | 1,347 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,322 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 1473

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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.