July 19, 2007

Check Form_Success for each Built-In

Many Built-Ins have the problem, that they don't throw exceptions. (only in the ON-ERROR)

Example: You want to navigate to the block Customer and wrote a typo:


Go_Block ('CUSTOMR');
Do_something_after_Go_Block;

Go_Block can't navigate to the block, because you wrote CUSTOMR. But no exception is thrown inside the PL/SQL-Block. This means, the code didn't stop and the execution of Do_something_after_Go_Block starts. This is a big problem in most cases!

Solution: Create a procedure Check_Builtin

PROCEDURE Check_Builtin IS
BEGIN
IF NOT Form_Success THEN
RAISE Form_Trigger_Failure;
END IF;
END;

Use this procedure after each Built-In:

BEGIN
Go_Block ('CUSTOMR');
Check_Builtin;
Do_something_after_Go_Block;
EXCEPTION
WHEN FORM_TRIGGER_FAILURE THEN
-- do something ...
END;

Also you can create your own Built-In for example Goto_Block instead of Go_Block: This new procedure works internally with the new Check_Builtin

PROCEDURE Goto_Block (P_Block IN VARCHAR2) IS
BEGIN
Go_Block (P_Block);
Check_Builtin;
Do_something_after_Go_Block;
END;

and then :

BEGIN
Goto_Block ('CUSTOMR');
Do_something_after_Go_Block;
EXCEPTION
WHEN FORM_TRIGGER_FAILURE THEN
-- do something ...
END;

Important: When you use this technique you have to write an exception-handling and check the FORM_TRIGGER_FAILURE.

This technique is similiar to Oracle's Check_Package_Failure, but this procedure can only be used, when you work with master-detail-relations.

use Check_Builtin
Gerd

2 comments:

Patrick Wolf said...

Hi Gerd,

if you really have a typo you will get a FRM-40104: Block doesn't exist when you specify a wrong block name. So Forms is showing an error message.

The only problem is that Forms proceeds with the code after the GO_BLOCK.

But normally you don't check for FORM_SUCCESS because of a possible typo, instead you check if Forms was able to navigate there. Eg in the case the validation failed in the current field.

About handling the FORM_TRIGGER_FAILURE exception. That's a very special exception which just says "done continue processing, but don't show any error". That's why you normally don't write an exception handler for that type of exception.

Just my thoughts about that.

Greetings
Patrick

Gerd Volberg said...

that's true. Checking validation is important too.

I added a line in the post, that the biggest problem is, that the execution didn't stop