0
CREATE TABLE Property
(
    Pid int,
    Branchid int,
    Ptype varchar(250),    
    Paddress varchar(250), 
    Pcity varchar(250),
    CurrentPrice number,
    Pstatus varchar(10),
    Pminprice number, 
    Pmaxprice number,
    Agentid int,
    Appointmentid int
);

insert into Property 
values (1, 1, 'House', '11 sherrad road E78EZ', 'London', 110000, 'Available', 199000, 800000, 11, 1); 
insert into Property 
values (2, 1, 'Flat', '21 sherrad road E78EZ', 'London', 210000, 'Available', 299000, 800000, 12, 2); 
insert into Property 
values (3, 1, 'Plot', '31 sherrad road E78EZ', 'London', 310000, 'Available', 399000, 800000, 13, 3); 
insert into Property 
values (4, 2, 'House', '42 sherrad road E78EZ', 'Newyork', 420000, 'Available', 1499000, 800000, 14, 4); 
insert into Property 
values (5, 2, 'Flat', '52 sherrad road E78EZ', 'Newyork', 520000, 'Available', 599000, 800000, 15, 5); 
insert into Property 
values (6, 2, 'Plot', '62 sherrad road E78EZ', 'Newyork', 620000, 'Available', 699000, 800000, 16, 6); 
insert into Property 
values (7, 3, 'House', '73 sherrad road E78EZ', 'Tokyo', 730000, 'Available', 799000, 800000, 17, 7); 
insert into Property 
values (8, 3, 'Flat', '83 sherrad road E78EZ', 'Tokyo', 830000, 'Available', 899000, 800000, 18, 8); 
insert into Property 
values (9, 3, 'Plot', '93 sherrad road E78EZ', 'Tokyo', 930000, 'Available', 999000, 800000, 19, 9); 

CREATE TABLE formerProperty
(
    Pid int,
    Branchid int,   
    Ptype varchar(250),
    Paddress varchar(250),
    Pcity varchar(250),
    CurrentPrice number,
    Pstatus varchar(10),
    Pminprice number,
    Pmaxprice number,
    Agentid int,
    Appointmentid int
);

CREATE OR REPLACE TRIGGER trg_after_delete_bill
AFTER delete
ON Property FOR EACH ROW
  
BEGIN

  INSERT INTO formerProperty VALUES(:OLD.Pid,
           :OLD.Branchid,:OLD.Ptype,:OLD.Paddress,:OLD.Pcity,
           :OLD.CurrentPrice,:OLD.Pstatus,:OLD.Pminprice, :OLD.Pmaxprice,:OLD.Agentid,:OLD.Appointmentid);
  
END;
DELETE FROM Property WHERE Pid= 1;

select * from formerProperty;
4

1 回答 1

0

您忘记使用分隔符:

CREATE OR REPLACE TRIGGER trg_after_delete_bill
AFTER delete
ON Property FOR EACH ROW
  
BEGIN

  INSERT INTO formerProperty VALUES(:OLD.Pid,
           :OLD.Branchid,:OLD.Ptype,:OLD.Paddress,:OLD.Pcity,
           :OLD.CurrentPrice,:OLD.Pstatus,:OLD.Pminprice, :OLD.Pmaxprice,:OLD.Agentid,:OLD.Appointmentid);
  
END;
/
DELETE FROM Property WHERE Pid= 1;

select * from formerProperty
于 2020-11-17T15:31:28.193 回答