Re: Form 5.0 Triggers
Date: 1998/02/27
Message-ID: <6d7hbo$hch_at_info.csufresno.edu>#1/1
In article <34F6DC30.BEAAE34E_at_vpha.ufl.edu>,
Frank W Phillips JR <FWP_at_vpha.ufl.edu> wrote:
>Based on a user request I am attempting to write a trigger that will
>commit a form record to the database after the last field is completed.
>The problem, I can not find a trigger that will allow this.
>Do_key(‘commit_form’) is a restricted procedure. When-Validate-Item and
>Post-Text-Item triggers only allow unrestricted procedures.
>
>The request is to have an alert after the last field is entered that
>asks the user to save, edit, or remove the record. Also, this is an
>accounting app and if the record is not committed to the DB the next
>time I pull the balance from the DB it will not reflect the uncommitted
>record that is still pending in the block.
>
>They also wish to have the save option display a new blank record (i.e.
>Next_Record;) but this too is a restricted procedure.
>
>I have not been using Forms for long, so any help would be great. Thanks
You have two options: Do it with a timer, or use a when-new-item-instance trigger on a hidden, navigable item that follows the last item.
If you use the when-new-item-instance trigger, you are not restricted
like you are by the validation triggers. Just set your last item's
autotab to true, and the cursor will automatically jump into the wnii
trigger if the last item validates. The first thing I would do in the
wnii trigger is:
Validate(Record_Scope);
If not form_success then
Go_Item('Block1.ColumnA');
raise form_trigger_failure;
End if;
- show the alert here --
Or if you do it with a timer, you can use the following method. In your When-Validate-Item or When-Validate-Record trigger, call a procedure that starts a timer. Here is how I like to do it:
Use this command in your validation trigger:
P01_Finish_Record('START');
The procedure should be something like this
Procedure P01_Finish_Record (Mode1 in varchar2 default null) is
Var1 Varchar2(20); -- etc.
Begin
If Mode1='START' then
--start the timer--
PLL_Start_Timer('P01_Finish_Record');
Else --Timer has expired, time to go to work...
If :system.cursor_block<>'BLOCK1' then
Go_Block('BLOCK1'); --the cursor could be anywhere
End if;
A:=Show_Alert('Save_Edit_Delete');
If A=Alert_Button1 then --delete
Clear_Block(no_validate);
Elsif A=Alert_Button2 then --edit
Go_Item('Blk.ColumnA');
Else -- Save
Commit_Form; Clear_Block; P02_Pull_The_Balance;
End if;
End if;
End P01_Finish_Record;
The form-level When-timer-expired trigger looks like this:
Declare
TIMER_NAM VARCHAR2(30):=GET_APPLICATION_PROPERTY(TIMER_NAME);
Timer_Nam Varchar2(30):=Get_Application_Property(Timer_Name);
Begin
If Timer_Nam = 'P01_Finish_Record' then
P01_Finish_Record;
End if;
End;
I use a PLL library with the following procedure:
PROCEDURE PLL_START_TIMER
-- Starts a forms timer, first checking whether one with the same
-- name already exists.
(TIMER_NAME IN VARCHAR2, DURATION IN NUMBER ) IS
TIMER_ID TIMER;
BEGIN
TIMER_ID := FIND_TIMER(TIMER_NAME);--Name of timer IF ID_NULL(TIMER_ID) THEN
TIMER_ID := CREATE_TIMER(TIMER_NAME,DURATION,NO_REPEAT); ELSE
SET_TIMER(TIMER_ID,DURATION,NO_REPEAT); END IF;
END PLL_START_TIMER; HTH
Steve Cosner
http://members.aol.com/stevec5088
Downloadable Quick Access utility form: Display and update any table. Received on Fri Feb 27 1998 - 00:00:00 CET