我是oracle的新手。 我想创建一个触发器来将表TRIGGER_TEST的行数据备份到表TRIGGER_TEST_BK中。但是显示无效。
这是架构和错误:
CREATE TABLE "OA_TEST"."TRIGGER_TEST"
( "ID" VARCHAR2(32) NOT NULL ENABLE,
"TYPE" NUMBER,
"TEXT" VARCHAR2(255),
"UPDATE_TIME" DATE,
PRIMARY KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "HCIS4J" ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "HCIS4J";
CREATE UNIQUE INDEX "OA_TEST"."SYS_C0063741" ON "OA_TEST"."TRIGGER_TEST" ("ID")
PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "HCIS4J";
CREATE TABLE "OA_TEST"."TRIGGER_TEST_BK"
( "ID" VARCHAR2(32) NOT NULL ENABLE,
"TT_ID" VARCHAR2(32) NOT NULL ENABLE,
"TYPE" NUMBER,
"TEXT" VARCHAR2(255),
"UPDATE_TIME" DATE NOT NULL ENABLE,
PRIMARY KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "HCIS4J" ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "HCIS4J";
CREATE UNIQUE INDEX "OA_TEST"."SYS_C0063745" ON "OA_TEST"."TRIGGER_TEST_BK" ("ID")
PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "HCIS4J";
触发:
SQL> create or replace trigger OA_TEST.TRI_BK_TRIGGER_TEST AFTER update or DELETE on OA_TEST.TRIGGER_TEST
2 FOR EACH ROW
3 begin
4 insert into OA_TEST.TRIGGER_TEST_BK(ID, TT_ID, TYPE, TEXT, UPDATE_TIME) values(sys_guid(), OLD.ID, OLD.TYPE, OLD.TEXT, sysdate)
5 end;
6 /
Warning: Trigger created with compilation errors.
当我显示错误时;
2/1 PL/SQL: SQL Statement ignored
2/129 PL/SQL: ORA-00933: SQL command not properly ended
3/4 PLS-00103: Encountered the symbol "end-of-file" when expecting
one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << close current delete fetch lock insert
open rollback savepoint set sql execute commit forall merge
pipe
我在做什么错?谁能帮忙?
在“插入到...”语句后添加分号。
create or replace trigger OA_TEST.TRI_BK_TRIGGER_TEST AFTER update or DELETE on OA_TEST.TRIGGER_TEST
FOR EACH ROW
begin
insert into OA_TEST.TRIGGER_TEST_BK(ID, TT_ID, TYPE, TEXT, UPDATE_TIME) values(sys_guid(), OLD.ID, OLD.TYPE, OLD.TEXT, sysdate);
END;
TRIGGER OA_TEST.TRI_BK_TRIGGER_TEST错误:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/3 PL/SQL: SQL Statement ignored
2/116 PL/SQL: ORA-00984: column not allowed here
答案 0 :(得分:3)
ORA-00933: SQL command not properly ended
似乎,在触发器主体中的“插入...”语句之后,您缺少了分号。