Link to home
Start Free TrialLog in
Avatar of anumoses
anumosesFlag for United States of America

asked on

Oracle forms- commit question

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
Avatar of flow01
flow01
Flag of Netherlands image

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.
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.
Avatar of anumoses

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Mark Geerlings
Mark Geerlings
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks. Handled in a different way.