如题我建了一个简单的表
我写了触发器,但没起作用
执行时查询的那语句就报错了,因为表的字段是可以用空值的,所以不用能约束!
create table test
(
id number not null,
name varchar2(64),
code varchar2(18)
)
我写了触发器,但没起作用
creater or replace trigger tg_test
before update of code on test
for each row
declare
cnt number;
exp_err exception;
begin
select conut(*) into from test where (code is not null) and code=:new.code;
if cnt!=0 then
raise exp_err;
end if;
exception
when exp_err then
raise _application_error(-22222,'重复');
end;
执行时查询的那语句就报错了,因为表的字段是可以用空值的,所以不用能约束!