Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GO_BLOCK in WHEN_VALIDATE Trigger

I'm working with oracle forms. I've a procedure I have to run whenever a specific field's value is modified. The procedure I have to execute contains a go_block instruction, which can't be used in the when_validate_item trigger. Is there anyway to bypass this?

EDIT

I have to use the when_validate_item, because the procedure I have to run has to be run when the field is modified, BUT BEFORE the validation is executed.

like image 263
Nacho321 Avatar asked Dec 15 '22 19:12

Nacho321


1 Answers

Usually there is a restriction on using GO_BLOCK or GO_ITEM on a WHEN-VALIDATE-ITEM. However there are a couple of ways to overcome this. One way is to use a WHEN-TIMER-EXPIRED trigger. Here is how-

WHEN-TIMER-EXPIRED

Begin    
if GET_APPLICATION_PROPERTY(TIMER_NAME) = 'NEW_TIMER' then    
   CALL_PROG_UNIT(); --This is your Procedure that calls the GO_BLOCK   
   /*Do rest of validation here*/
end if;
END;

WHEN-VALIDATE-ITEM

DECLARE    
  timer_id TIMER;    
Begin        
  timer_id := CREATE_TIMER('NEW_TIMER',1,NO_REPEAT);    --set a short timer so that the WHEN-TIMER-EXPIRED trigger is fired immediately
End;

What happens is - This will create & expire the timer as soon as the CREATE_TIMER function is called and then the form level trigger WHEN-TIMER-EXPIRED will check the expired timer name and call your program unit that has the GO_BLOCK. Hope this helps.


UPDATE

Mr Jeffery Kemp wanted to see proof that this solution works. So here it is-

An Oracle form with two Blocks BLOCK1 and BLOCK2 with text items on it

enter image description here

W-V-I Trigger

enter image description here

W-T-E Form Trigger. This calls a PROGRAM UNIT P_CALL_PROC with GO_BLOCK function call first and then does some validations on the field Number 2.

enter image description here

Here is P_CALL_PROC

enter image description here

And here is the result-

enter image description here

And

enter image description here

Here is a Youtube link to see the Form in action.

like image 160
AnBisw Avatar answered Dec 30 '22 18:12

AnBisw