Skip to Main Content
  • Questions
  • Validate all required fields before committing form

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Jean.

Asked: March 19, 2017 - 9:54 am UTC

Last updated: March 22, 2017 - 1:43 am UTC

Version: Oracle Forms 11g

Viewed 10K+ times! This question is

You Asked

Dears,

I have a master-detail form in which I want to validate all required fields before committing.

When I press Save (Key-Commit), I have a procedure that loops on records in the detail block.

If a required field is null in the detail block, I want the form to return a message "Field must be entered" and focus the cursor on this item like it usually does if I try to navigate out of it.

I tried different validation scopes (Form, data block, record, item) but none of them is doing the job I want.

I know that it works somehow because I worked in a company where they had this code implemented in the beginning of the Key-Commit trigger but I can't figure it out anymore.

Note: I know that I can raise an alert when looping through the records but I don't want to do that because I know that it can be done in a much proper way.

Thank you,
Jean Maatouk.

and Connor said...

Not sure what you mean by:

"I tried different validation scopes (Form, data block, record, item) but none of them is doing the job I want."

If you set "Validation Unit" to Block (or Form), then wont the standard validations occur, but not immediately, ie, you would still get the usal "Field must be entered" but at block exit time (or whatever scope you opted for).

Or in the pre-commit (or similar trigger level at which you're about to save/exit the block), you could perhaps call:

validate(block_scope);

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Thanks for the response

Jean Maatouk, March 20, 2017 - 12:44 pm UTC

Dear Connor,

Maybe I wasn't clear enough.

Please consider the following scenario:

I have a master-detail form.
Cursor is at detail block. I press create record. A new record is created. The first item of that record is required. If I press save without filling that item, I want the message "Field must be entered" to appear in the status bar (like it usually does) before executing the code in my Key-Commit trigger at form level.

What is happening now is that the code in my Key-Commit trigger is executed before the "Field must be entered" appears.

I hope it's much clearer now.

Thank you again.
Connor McDonald
March 22, 2017 - 1:43 am UTC

Sorry, I dont have Forms installed anywhere anymore so I cant test my theories for you.

But if the item is marked as required, then I would have expected a call like:

validate(block_scope);
check_package_failure;

would stop the user right there and then.

If I'm not being much help :-(, then perhaps try the Forms forums

https://community.oracle.com/community/development_tools/forms/content


No problem, Thank you anyway

Jean Maatouk, March 23, 2017 - 11:40 am UTC

Dear Connor,

I solved my problem by clearing the record before saving.

It's not what I wanted to do but it's a fair workaround.

Thank you,
Jean Maatouk.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library