oracle中触发器根据条件判断如果存在同样的数据不能插入怎么写?
2个回答
展开全部
CREATE OR REPLACE TRIGGER TRI_INSERT_TB
BEFORE INSERT
ON TB
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
declare
Duplicate_Exception Exception;
PRAGMA EXCEPTION_INIT(Duplicate_Exception, -2293);
BEGIN
IF (重复) THEN
RAISE Duplicate_Exception;
END IF;
END ;
/
SHOW ERRORS;
把“重复”改成你要判断的条件
BEFORE INSERT
ON TB
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
declare
Duplicate_Exception Exception;
PRAGMA EXCEPTION_INIT(Duplicate_Exception, -2293);
BEGIN
IF (重复) THEN
RAISE Duplicate_Exception;
END IF;
END ;
/
SHOW ERRORS;
把“重复”改成你要判断的条件
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询