Oracle Apex 验证 - 有效产品名称
我在这里有一个验证初学者的问题:
我有一个选择列表项,选项: 产品 SKU
如果用户选择 SKU 选项,则会显示一个新的文本字段项目,供客户记下 SKU 编号。 然后,我的验证会尝试阻止插入无效的 SKU。 这就是我到目前为止所得到的:
declare
v_rows_approved_min number;
v_rows_approved_max number;
err varchar2(300);
begin
if :P8_PRODUCT_OR_SKU = 'SKU' -- THIS IS MY SELECT LIST ITEM
then
err := 'Not a valid SKU';
v_rows_approved_min := 1;
select count(*) into v_rows_approved_max from SKU_TABLE;
for cur_a in (select SKU from SKU_TABLE)
loop
exit when v_rows_approved_min > v_rows_approved_max;
if :P8_SKU = cur_a.SKU
then return err;
else null;
end if;
v_rows_approved_min := v_rows_approved_min + 1;
end loop;
else null;
end if;
end;
不确定这里发生了什么,有人可以帮忙吗?
谢谢!
I have a Validation beginner's question here:
I have a select list item, options:
Product
SKU
If the user selects the SKU option a new textfield Item is shown for the customer to write down the SKU number.
My validation then tries to prevent an invalid SKU to be inserted.
This is what I have so far:
declare
v_rows_approved_min number;
v_rows_approved_max number;
err varchar2(300);
begin
if :P8_PRODUCT_OR_SKU = 'SKU' -- THIS IS MY SELECT LIST ITEM
then
err := 'Not a valid SKU';
v_rows_approved_min := 1;
select count(*) into v_rows_approved_max from SKU_TABLE;
for cur_a in (select SKU from SKU_TABLE)
loop
exit when v_rows_approved_min > v_rows_approved_max;
if :P8_SKU = cur_a.SKU
then return err;
else null;
end if;
v_rows_approved_min := v_rows_approved_min + 1;
end loop;
else null;
end if;
end;
Not sure what's going on here, can anyone help please?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码过于复杂。它检查表中是否存在页面项值,如果找到匹配则返回错误。这是通过一个带有一些附加逻辑的循环来完成的,当迭代次数达到选择计数时退出循环。最后一个逻辑是不需要的。如果表包含 5 行,则循环将进行 5 次迭代。无需从表 (v_rows_approved_max) 中执行
SELECT 计数
,然后检查每次迭代是否尚未达到该数字...此外,没有
RETURN
语句如果找不到匹配项,则将其添加到末尾。这是重写的尝试:
但是......
这可以大大简化。
创建“返回的行”类型的验证
来源:
错误消息:不是有效的 SKU
服务器端条件(类型项目 = 值):项目:P8_PRODUCT_OR_SKU;值:SKU
这执行完全相同的操作。
This code is overly complex. It checks if a page item value exists in a table and returns an error if a match is found. This is done with a loop with some additional logic to exit the loop with the number of iterations reaches the select count. That last logic is not needed. If a table contains 5 rows, then the loop will have 5 iterations. No need to do a
SELECT count
from the table (v_rows_approved_max) and then check every iteration if that number has not been reached yet...Also, there is no
RETURN
statement if not match is found, so that is added at the end.Here is an attempt at a rewrite:
however...
This can be greatly simplified.
Create a validation of type "Rows returned"
Source:
Error Message: Not a valid SKU
Server Side condition (Type Item = Value): Item: P8_PRODUCT_OR_SKU; Value: SKU
This does exactly the same thing.