FutureDBA-
asked on
Trigger PLSQL on column change
Hello Experts,
I have 2 tables, I want to create a trigger to execute a PLSQL block when the status on CREDIT_HEADER changes from null to 1
I have 2 tables, I want to create a trigger to execute a PLSQL block when the status on CREDIT_HEADER changes from null to 1
BEGIN
INSERT INTO CREDIT_MASTER (CID, CDATE, CHAIN, CUSTOMER, REP, ROUTE, CRAMT)
SELECT
H.CID,
H.CDATE,
H.CHAIN,
H.CUSTOMER,
H.REP,
NULL ROUTE,
sum(QTY*ITMPRC) CRAMT
FROM CREDIT_HEADER H, CREDIT_DETAIL D
WHERE H.CID = D.CID
AND H.STATUS is 1
GROUP BY
H.CID,
H.CDATE,
H.CHAIN,
H.CUSTOMER,
H.REP;
commit;
update CREDIT_HEADER set status = 2 where status = 1 and REP is not null;
commit;
END;
CREDIT_HEADER
-----------------------------
CID NOT NULL VARCHAR2(9)
CDATE DATE
CHAIN VARCHAR2(6)
CUSTOMER VARCHAR2(6)
CNAME VARCHAR2(20)
CCOMMENT VARCHAR2(120)
REP VARCHAR2(15)
STATUS VARCHAR2(2)
CREDIT_MASTER
----------------------------
desc credit_master
Name Null Type
-------- -------- ------------
CID NOT NULL VARCHAR2(9)
CDATE DATE
CHAIN VARCHAR2(6)
CUSTOMER VARCHAR2(6)
REP VARCHAR2(15)
ROUTE VARCHAR2(20)
CRAMT NUMBER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
but the logic of what im trying to do is that
Please define "doesn't work". Does it cause your server to crash? Your monitor to turn pink?
Can you also provide a simple test case with data and expected results?
It would also help if you could post the trigger code you tried.
Can you also provide a simple test case with data and expected results?
It would also help if you could post the trigger code you tried.
ASKER