Oracle forms- commit question

anumoses
anumoses used Ask the Experts™
on
I have a code in key-commit of oracle forms that does some validation and gives a warning message. When user is trying to save, it give me the correct message. But they exit out it asks do you want to save, if I say YES, it save but does not give warning message and stop. So what trigger do I need. I tried on-commit. but go_block,. first_record are illegal
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
flow01IT-specialist

Commented:
Is it possible to give the code  you want to execute ?  Maybe we can find a workaround, to avoid the navigation.
One possibilty I'm thinking of is to use the post-builtin in the on-commit to propagate the changes in the form to the database (insert,update,delete) and  perform your validations on the database records instead of the data in form  before issuing the commit-form built-in to execute the actual commit in the database.
Another way can be to keep track of the relevant data that you need for checking (for example in a package either in the form or in the database or in a temporary table )  and do your validation on that kept data.
Mark GeerlingsDatabase Administrator

Commented:
Without knowing exactly what you want to do, it is hard for us to know the best way to get the job done.

It is true that an "ON-COMMIT" trigger cannot do form navigation activities, like GO_BLOCK, FIRST_RECORD, etc.  A "KEY-COMMIT" trigger can do form navigation activities like that.

But, I don't recommend using a "KEY-COMMIT" trigger to do validation.  I like to do validation earlier in the process, ideally in WHEN-VALIDATE-ITEM triggers, or at least in PRE-INSERT or PRE-UPDATE triggers.  I use a program unit that can be called from both a PRE-INSERT and a PRE-UPDATE trigger, if I need the same logic to happen for both events.

Author

Commented:
I tried using this code. declared global  variable

key-commit

:GLOBAL.COMMIT := '1';
COMMIT_FORM;
:GLOBAL.COMMIT := '0';

pre-commit

DEFAULT_VALUE('0','GLOBAL.COMMIT');
IF :GLOBAL.COMMIT = '0' THEN
ERASE('GLOBAL.COMMIT');
      msg_alert('Warning! This invoice must be in balance in order to save & close.','E',true);
RAISE FORM_TRIGGER_FAILURE;
END IF;

This is working
Database Administrator
Commented:
Are you sure that is doing the validation that you want?  It looks to me like with those two triggers, you will never get the warning message displayed.

Author

Commented:
thanks. Handled in a different way.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial