在oracle sql中,我在删除插入表后创建但收到此错误PLS-00103:遇到符号“DELETE”[重复]

Posted

技术标签:

【中文标题】在oracle sql中,我在删除插入表后创建但收到此错误PLS-00103:遇到符号“DELETE”[重复]【英文标题】:in oracle sql im creating after delete insert into table but getting this error which PLS-00103: Encountered the symbol "DELETE" [duplicate] 【发布时间】:2020-11-17 15:26:22 【问题描述】:
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;

【问题讨论】:

您可以在下面以绿色勾号形式给出答案,并且可能获得支持的社区用户将获得帮助!!! 【参考方案1】:

您忘记使用分隔符:

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

【讨论】:

以上是关于在oracle sql中,我在删除插入表后创建但收到此错误PLS-00103:遇到符号“DELETE”[重复]的主要内容,如果未能解决你的问题,请参考以下文章

Oracle(创建index)

Python学习---Django误删除sql表后,如何创建数据

有关hibernate.hbm2ddl.auto create删除原来的表后无法创建的问题

是否可以在 Oracle10g 中的同一查询中进行插入和删除?

同时创建两条单链表,头插法插入节点,遍历,查找,删除,求长度,冒泡排序,反转,2条有序链表链接成一条链表后依然有序

django 删除数据库表后重新同步的方法