如果用户尝试保存值,我的 table 已经存在于我的基于 Oracle Apex 表单的应用程序中,如何显示警报
How to show alert if user tries to save values, that are already present my table for my Oracle Apex Form based application
我在基于 Oracle APEX 的应用程序中有一个表单,我想对提交按钮进行验证,以便两个特定条目的组合,如果它们已经存在于 SQL table/View, 我想显示一个警报,例如 "The entry for this combination of values of A and B already exists, please enter correct values."
如果那些 两个特定条目 由两个表单项(例如 :P1_ONE
和 :P2_TWO
)表示,则验证过程可能是一个函数returns 错误文本,例如
declare
l_cnt number;
retval varchar2(200);
begin
select count(*)
into l_cnt
from your_table t
where t.column_one = :P1_ONE
and t.column_two = :P1_TWO;
if l_cnt > 0 then
retval := 'The entry for this combination already exists';
end if;
end;
查询本身可能需要修改,具体取决于您描述问题的确切含义;我是这么理解的。
那么你应该对 table 有一个唯一约束,并让它验证传入的数据。
任何违反此约束的行为都将引发异常,可以在 APEX error handling procedure.
中进行转换
我在基于 Oracle APEX 的应用程序中有一个表单,我想对提交按钮进行验证,以便两个特定条目的组合,如果它们已经存在于 SQL table/View, 我想显示一个警报,例如 "The entry for this combination of values of A and B already exists, please enter correct values."
如果那些 两个特定条目 由两个表单项(例如 :P1_ONE
和 :P2_TWO
)表示,则验证过程可能是一个函数returns 错误文本,例如
declare
l_cnt number;
retval varchar2(200);
begin
select count(*)
into l_cnt
from your_table t
where t.column_one = :P1_ONE
and t.column_two = :P1_TWO;
if l_cnt > 0 then
retval := 'The entry for this combination already exists';
end if;
end;
查询本身可能需要修改,具体取决于您描述问题的确切含义;我是这么理解的。
那么你应该对 table 有一个唯一约束,并让它验证传入的数据。
任何违反此约束的行为都将引发异常,可以在 APEX error handling procedure.
中进行转换