【发布时间】:2021-02-01 10:37:45
【问题描述】:
我有一个表的列必须小于某个值,问题是这个值存储在另一个表中,所以我无法引用它,所以经过一些研究我发现我可以使用一个函数并调用它在检查约束中,这是我的功能
create or replace FUNCTION check_caution(id_cont in NUMBER)
return number
as res number ;
begin
select amount_contract*caution_offre_f*0.01 into res from contract
where id_contract=id_cont;
return res;
end check_caution;
该功能运行良好,我对其进行了测试。 这是我的检查约束
alter table caution_exe
add CONSTRAINT check_amount
check (caution_exe.amount_caution<=check_caution(caution_exe.id_contract));
但这是我尝试添加后得到的消息
ORA-00904: "CHECK_CAUTION": invalid identifier
00904. 00000 - "%s: invalid identifier"
【问题讨论】:
-
这在 Oracle 中根本不可能
标签: oracle triggers stored-functions check-constraints