AFTER DELETE
ON table_name
[ FOR EACH ROW ]
DECLARE
-- variable declarations
BEGIN
-- trigger code
EXCEPTION
WHEN ...
-- exception handling
END;
|
CREATE TABLE orders
| ||
|
(
|
order_id
|
number(5),
|
|
|
quantity
|
number(4),
|
|
|
cost_per_item
|
number(6,2),
|
|
|
total_cost
|
number(8,2)
|
|
);
| ||
We could then create an DELETE UPDATE trigger as follows:
AFTER DELETE
ON orders
FOR EACH ROW
v_username varchar2(10);
SELECT user INTO v_username
FROM dual;
INSERT INTO orders_audit
( order_id,
quantity,
cost_per_item,
total_cost,
delete_date,
deleted_by)
VALUES
( :old.order_id,
:old.quantity,
:old.cost_per_item,
:old.total_cost,
sysdate,
v_username );
1217



被折叠的 条评论
为什么被折叠?



