简体   繁体   English

列验证未在交互式网格中触发 Oracle APEX

[英]Column Validation not firing in Interactive Grid Oracle APEX

I'm developing a simple application in Oracle APEX and one of the requirements is to create an error message if a duplicate column (which is also the UK of the table) is saved to the Interactive Grid.我正在 Oracle APEX 中开发一个简单的应用程序,其中一个要求是在将重复列(也是表的英国)保存到交互式网格时创建错误消息。 I've created a support package and then a column validation in APEX that calls the function in the support package.我创建了一个支持 package,然后在 APEX 中创建了一个列验证,它在支持 package 中调用 function。

When I first implemented the code and the call, everything was working and the correct error message was displayed.当我第一次实现代码和调用时,一切正常,并显示了正确的错误消息。 However, I think I unknowingly modified a property setting or something because now I cannot get the validation to fire -- if the user enters a duplicate column value and presses save, they get the generic "constraint violation" error message that Oracle raises.但是,我认为我不知不觉地修改了属性设置或其他内容,因为现在我无法触发验证——如果用户输入重复的列值并按保存,他们会收到 Oracle 引发的通用“约束违规”错误消息。 The only IG Process in this app is the Automatic Row Processing - Save button.此应用程序中唯一的 IG 进程是自动行处理 - 保存按钮。

Does anyone have know why the column validation is being ignored?有谁知道为什么忽略列验证? I have gone through the error stack of the "constraint violation" and all I am seeing is the Save process and Oracles generic error messages.我已经检查了“违反约束”的错误堆栈,我所看到的只是保存过程和 Oracles 通用错误消息。

Support Package Function:支持Package Function:

`FUNCTION Prod_Family_Exists (
     i_id                    IN NUMBER
    ,i_prod_family           IN VARCHAR2
        ) RETURN BOOLEAN IS
  v_cnt        NUMBER;
BEGIN
  SELECT COUNT(*)
    INTO v_cnt
    FROM adm_prod_families 
   WHERE prod_family = i_prod_family
     AND id <> i_id
   ;
   
   IF v_cnt = 0 THEN
    RETURN(FALSE);
   ELSE
    RETURN(TRUE);
   END IF;

EXCEPTION
  WHEN OTHERS THEN
    RETURN(FALSE);
    
END Prod_Family_Exists;

END Z_TEST;`

Validation Call in APEX - PL/SQL Function (Returning Boolean): APEX 中的验证调用 - PL/SQL Function(返回布尔值):

BEGIN 

    IF z_test.prod_family_exists( i_id                => :id
                                 ,i_prod_family       => :prod_family)
    THEN 
      RETURN FALSE;
    ELSE
      RETURN TRUE;
    END IF;
END;

Based on the image below and the code I've provided, my custom error message would only be raised if the result from the validation returned FALSE right?根据下图和我提供的代码,只有在验证结果返回 FALSE 时才会引发我的自定义错误消息,对吗? Is the code bad?代码不好吗?

用于插入具有重复列值的记录的会话 - 返回 true

I figured this out.我想通了。 The code for the validation call to the support package function needed to be modified.验证调用支持 package function 的代码需要修改。 New code:新代码:

BEGIN 
    IF z_test.prod_family_exists( i_id             => NVL(:id,0)
                                 ,i_prod_family    => :prod_family)
    THEN 
      RETURN FALSE;
    ELSE
      RETURN TRUE;
    END IF;
END;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM