触发器语法上求有点困惑
Create Table customers
(
customerid Number(4) Primary Key,
customername Varchar2(20)
);
Create Table orders
(
orderid Number(4) Primary Key,
orderdate Date,
orderstatus Char(1),
customerid Number(4)
);
Create Or Replace View v_co As Select c.customerid,c.customername,o.orderid,o.orderdate,o.orderstatus From customers c,orders o Where c.customerid = o.customerid;
--------------建了这两个表和一个视图
Create Or Replace Trigger v_co_insert_tgr Instead Of Insert On v_coBegin Insert Into customers(customerid,customername) Values(:new.customerid,:new.customername); Insert Into orders(orderid,orderdate,orderstatus,customerid) Values(:new.orderid,:new.orderdate,:new.orderstatus,:new.customerid); --Commit;End;
Values(:new.customerid,:new.customername); 悲剧啊 学过的忘记了,这句话什么意思
cnCREATE [OR REPLACE] TRIGGER trigger_nametiming event1 [ORevent2 ORevent3]ONtable_name[REFERENCING OLD AS old | NEW AS new][FOR EACH ROW][WHEN (condition)]trigger_body
看了语法上是 [REFERENCING OLD AS old | NEW AS new] 这句不太理解
------解决方案--------------------
插入数据的时候,触发把新的数据插入~~~