After Insert Trigger. how do you assign value to variable??
715388Aug 3 2009 — edited Aug 3 2009Was wondering if I could get some assistance please... I have no experience in PL\SQL... The below trigger fires on insert of another table and this trigger adds rows to another table... When trying to assign "bdate" a value from another table, I can't compile trigger... Getting ORA-04084 when trying to compile... Can someone tell me what's wrong in the code please??
Thanks,
Curtis
CREATE OR REPLACE TRIGGER "HKSM"."CHILLPK_IAR" AFTER
INSERT ON "CHILLPACK" FOR EACH ROW
DECLARE
bdate SAPUPLOAD.mfgdate%TYPE;
BEGIN
IF :New.sku NOT IN ('REWORK','EMT') THEN
IF TO_CHAR(:New.adddate, 'HH24:MI:SS') < '04:00:00' THEN
-- adddate = production date, set to previous day
:New.adddate := :New.adddate -1;
END IF;
-- bdate = mfgdate (kill date from inventory)
SELECT mfgdate INTO bdate FROM INVENTORY
WHERE RTRIM(containerkey) = RTRIM(:New.containerkey)
AND RTRIM(sku) = RTRIM(:New.sku);
INSERT INTO SAPUPLOAD (
sku,
qty,
wgt,
mfgdate,
pflag,
rtype,
containerid,
batchdate)
VALUES (
:New.sku,
:New.traysproduced,
:New.weightproduced,
:New.adddate,
NULL,
'CREATE',
:New.containerkey,
bdate);
END IF;
END;