在 Oracle Forms 中向 table 插入值时如何删除 FRM-40401

How to remove FRM-40401 when inserting values to table in Oracle Forms

在 table 中插入值后,我似乎无法显示消息。

它一直显示 FRM-40401 而不是

 CREATE TABLE NUMBERS
 (
 NUM1 INT
 );

虽然我的 WHEN_BUTTON_PRESSED 代码是

 DECLARE
   VAR_VALUE INT;
 BEGIN
   VAR_VALUE := :MYNUMBERS.MYVALUE;

   INSERT INTO NUMBERS (NUM1) VALUES (VAR_VALUE);   

   MESSAGE('YOU INSERTED '||var_value);
   commit;
 END;

提交提交时,可能会出现 FRM-40400FRM-40401 以分别显示事务发生或事务期间未出现问题。

要抑制此类消息,可以考虑两种方法;

  1. 以下内容可以放在 ON-MESSAGE 表单级别的触发器中:

    If  Message_Code in (40400, 40401) Then 
         null;  
    End If;
    
  2. 或者,可以将以下内容放入触发器中 提交已发布

    (可能在 WHEN-BUTTON-PRESSED 触发器内):

    :system.message_level := '5'; 
    -- to suppress all messages with severity below level 5.
     commit;
    :system.message_level := '0';
    

    其中消息级别是:

    0  - Default value. All types of messages from the other levels of severity. 
    5  - Reaffirms an obvious condition. 
    10 - Indicates that the operator has made a procedural mistake. 
    15 - Declares that the operator is attempting to perform a function 
         for which the form is not designed. 
    20 - Indicates a condition where the operator cannot continue an intended 
         action due to a problem with a trigger or another outstanding condition. 
    25 - Indicates a condition that could result in the form performing incorrectly.
    

I can't seem to display the message after inserting a value into the table. It keeps on displaying ORA40401 instead

这是因为

MESSAGE('YOU INSERTED '||var_value);
commit;

如果您 运行 表单处于调试模式,您会看到该消息实际上 显示在屏幕底部,但是 commit - 随后 - 立即覆盖之前的消息。

最简单的"fix"方法是以提示的方式显示消息,即在屏幕上弹出window,这可以通过随后的两个MESSAGE 调用:

MESSAGE('YOU INSERTED '||var_value);
MESSAGE('YOU INSERTED '||var_value);
commit;

顺便说一句,你不需要局部变量;改为插入项目值:

INSERT INTO NUMBERS (NUM1) VALUES (:MYNUMBERS.MYVALUE);