Avatar of anumoses
anumoses
Flag 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
Oracle Database

Avatar of undefined
Last Comment
anumoses

8/22/2022 - Mon
flow01

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 Geerlings

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.
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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Mark Geerlings

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
anumoses

ASKER
thanks. Handled in a different way.