oracle 表单抑制错误消息并捕获 frm-40350
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22192151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Forms Suppress Error Message And Catch frm-40350
提问by J?cob
I have the following code on a button's WHEN-BUTTON-PRESSED
trigger
我在按钮的WHEN-BUTTON-PRESSED
触发器上有以下代码
BEGIN
SYNCHRONIZE;
populate_maximo_records;
END;
There will be a scenario that there will not be any records ti populate in block. If there are no records, currently it is throwing the following error message
会出现这样的情况,即不会在块中填充任何记录。如果没有记录,目前是抛出以下错误信息
frm-40350 query caused no records to be retrieved
Instead, I would like to suppress the above message and display a customized message. How can I do this?
相反,我想取消上述消息并显示自定义消息。我怎样才能做到这一点?
采纳答案by nightfox79
You can use system.message_level to suppress messages from the system: You have levels of messages: 0, 5, 10, 15, 20, 25, >25
您可以使用 system.message_level 来抑制来自系统的消息:您有消息级别:0、5、10、15、20、25、>25
In a trigger, you can specify that only messages above a specified severity level are to be issuedby the form. You do this by assigning a value to the MESSAGE_LEVEL
在触发器中,您可以指定表单仅发出高于指定严重性级别的消息。您可以通过为 MESSAGE_LEVEL 分配一个值来做到这一点
example:
例子:
declare
old_message_level number;
begin
:old_message_level := :system.message_level;
:system.message_level := 20; -- suppresses most errors
commit; -- action you want to do without messages or errors
:system.message_level := old_message_level;
end;
If you hold any errors occurring in a variable or in a table you then show your own message after this code by checking your variable if an error has occurred.
如果您保存在变量或表中发生的任何错误,则在此代码之后通过检查您的变量是否发生错误来显示您自己的消息。
回答by DJPeter
You can use the On-Message or On-Error trigger to trap any internal forms message or error. FRM-40350 is classified as type informative (can be checked in Forms help) so it has to be handled in On-Message trigger. The code for trapping the message should be something like this:
您可以使用 On-Message 或 On-Error 触发器来捕获任何内部表单消息或错误。FRM-40350 被归类为信息类型(可以在 Forms 帮助中查看),因此它必须在 On-Message 触发器中处理。捕获消息的代码应该是这样的:
IF message_code = 40350 THEN
Message('Your custom message');
ELSE
Message(message_type||'-'||TO_CHAR(message_code)||':'||message_text);
END IF;
Please notice that 'On' triggers replaces implicit form functionality so if you in the example leave out the ELSE statement then you will hide all other forms messages! With the On-Error trigger it is essential that you remember to use RAISe after displaying your own message otherwise forms will continue as the error never had happened!
请注意,“On”触发器替换了隐式表单功能,因此如果您在示例中省略了 ELSE 语句,那么您将隐藏所有其他表单消息!对于 On-Error 触发器,您必须记住在显示您自己的消息后使用 RAISe,否则表单将继续,因为错误从未发生过!
IF error_code = 50026 THEN
Message('My Own message');
RAISE FORM_TRIGGER_FAILURE;
ELSE
Message(error_type||'-'||TO_CHAR(error_code)||':'||error_text);
RAISE FORM_TRIGGER_FAILURE;
END IF;