OK 理论上用FOREIGN KEY 和PRIMARY KEY,及CONSTRAINTS CHECK来实现我清楚.现在具体点 我有个表,有几个字段(X,Y,Z),这里X,Y,Z只是ID,具体的值从另外的表中获得者,要满足的约束是 ax+by+cz=d 约束怎么写?
好像只有通过trigger来完成了。
create or replace trigger test before insert or update of (x,y,z) on yourtable for each row declare d number; begin select field into d from another_table; if a*:new.x+ b*:new.y+c*new.z <> d then RAISE_APPLICATION_ERROR(-20011,'.....'); end if; end; / 你的应用程序可以捕获20011这个错误码、
理论上用FOREIGN KEY 和PRIMARY KEY,及CONSTRAINTS CHECK来实现我清楚.现在具体点
我有个表,有几个字段(X,Y,Z),这里X,Y,Z只是ID,具体的值从另外的表中获得者,要满足的约束是
ax+by+cz=d
约束怎么写?
before insert or update of (x,y,z) on yourtable
for each row
declare
d number;
begin
select field into d from another_table;
if a*:new.x+ b*:new.y+c*new.z <> d then
RAISE_APPLICATION_ERROR(-20011,'.....');
end if;
end;
/
你的应用程序可以捕获20011这个错误码、
2、TRIGGERS
3、APPLiCATION CODE具体用法你看一下书吧