我有这个脚本。基本上增加表中的一个主键。
CREATE OR REPLACE FORCE TRIGGER SISD_OWNER.TRG_SN_MAP_UNIT_RELA_SEQ
BEFORE INSERT ON SISD_OWNER.ADV_SN_MAP_UNIT_RELA
FOR EACH ROW
DECLARE
m_next_seq_num NUMBER := 0;
BEGIN
IF :new.SEQUENCE_NUMBER is null THEN
select
ADV_SN_MAP_UNIT_RELA_SEQ.NextVal
into m_next_seq_num
from dual;
:new.SEQUENCE_NUMBER := m_next_seq_num;
END IF;
END;
在sqlplus(cmd)上运行时,我得到了:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/28 PLS-00103: Encountered the symbol "end-of-file" when expecting
one of the following:
* & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || multiset member submultiset
不确定错误究竟是什么?
答案 0 :(得分:1)
如果您的数据库版本为11g或更高。 然后使用简化代码并提高工作效率的新功能。
CREATE OR REPLACE TRIGGER SISD_OWNER.TRG_SN_MAP_UNIT_RELA_SEQ
BEFORE INSERT ON SISD_OWNER.ADV_SN_MAP_UNIT_RELA
FOR EACH ROW
DECLARE
BEGIN
IF :new.SEQUENCE_NUMBER is null THEN
:new.SEQUENCE_NUMBER := ADV_SN_MAP_UNIT_RELA_SEQ.NextVal;
END IF;
END;
答案 1 :(得分:0)