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

时间:2018-06-09 14:34:33

标签: oracle oracleforms

在将值插入表格后,我似乎无法显示该消息。它继续显示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;

2 个答案:

答案 0 :(得分:0)

当发出提交时,可能会出现 FRM-40400 FRM-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.
    

答案 1 :(得分:0)

  

在将值插入后,我似乎无法显示消息   表。它继续显示ORA40401而不是

这是因为

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

如果您在调试模式下运行该表单,您会在屏幕底部看到显示 的消息,但后面的commit会立即覆盖以前的消息

“修复”它的最简单方法是以警报的方式显示消息,即屏幕上的弹出窗口,并且可以通过两个后续的MESSAGE调用来完成:

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

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

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