Hi,
I'm having a bit of trouble getting the syntax correct for DB2, please can someone help.
Here is the statement i want to add:
As you can see, i'm trying to archive the order table when there's 50 entries and then empty it.
Any help is appreciated )
Cheers,
Jim
I'm having a bit of trouble getting the syntax correct for DB2, please can someone help.
Here is the statement i want to add:
Code:
CREATE TRIGGER archive
AFTER INSERT ON order
REFERENCING NEW AS new
FOR EACH ROW MODE DB2SQL
DECLARE max INTEGER;
BEGIN
SELECT COUNT(*) INTO max
FROM order
WHERE cno = :new..cno;
IF max = 50
INSERT INTO order_archive (oa_cno, oa_bno, oa_when, oa_qty)
VALUES (order.cno, order.bno, order.when, order.qty)
DELETE FROM order
END IF;
END;
Any help is appreciated )
Cheers,
Jim