I'm using an Oracle database and need some help - triggers are something I struggle to understand.
I need a trigger for when I insert or update a row in Table A so that it updates a column on Table B.
Table A includes:
CREATE TABLE "RELEASE_RECORD"
( "LABNUMBER" VARCHAR2(20 BYTE) NOT NULL ENABLE,
"RELEASED_BY" VARCHAR2(15 BYTE) NOT NULL ENABLE,
PRIMARY KEY ("LABNUMBER", "RELEASED_BY")
Table B includes:
CREATE TABLE "AUTO_EMAIL"
( "LABNUMBER" VARCHAR2(20 BYTE),
"EMAIL" VARCHAR2(1000 BYTE),
"STATUS" VARCHAR2(1 BYTE),
PRIMARY KEY ("LABNUMBER")
And I have a trigger like this:
create or replace trigger TRG_AUTO_EMAIL
AFTER INSERT or UPDATE on RELEASE_RECORD
FOR EACH ROW
DECLARE v_labnumber number;
set STATUS = 'N'
WHERE labnumber = v_labnumber;
Everytime I insert or update a record in RELEASE_RECORD table, I want the status in AUTO_EMAIL update into "N" automatically.
But it seems that my trigger did not work.