[Top of Document]

Appendix B: WHEN-NEW-ITEM-INSTANCE Triggers

Introduction

Your WHEN-NEW-ITEM-INSTANCE trigger may have code that navigates to another location, does something and then comes back to the same item. In SQL*Forms 3.0, the ON-NEW-FIELD-INSTANCE trigger will detect that the cursor did not change position and hence will not fire a second time. However, the WHEN-NEW-ITEM-INSTANCE trigger in Oracle Forms 4.0 and 4.5 will always fire whenever the cursor changes location (either through user navigation, or as a result of calling built-ins) and lands in that item.

As a result, your WHEN-NEW-ITEM-INSTANCE triggers could be in an infinite loop. For example, the following WHEN-NEW-ITEM-INSTANCE trigger will be in an infinite loop after the upgrade.

WHEN-NEW-ITEM-INSTANCE trigger sample:

 
   declare
   ...
   begin
   ...
     next_item;
   ...
     previous_item;
   ...
   end;

The Solution

In order to avoid this, you have to create a parameter wnii and wrap the following if-statement around the code in those WHEN-NEW-ITEM-INSTANCE triggers that have code which will cause the cursor to be put in the same item.

 Parameter Name|Data Type|Maximum Length|Default Value|Comments

 wnii          character          1                    = t when we want to
                                                         execute the code in the
                                                         WHEN-NEW-ITEM-
                                                         INSTANCE trigger
                                                         = f otherwise
   
   if downii then
     unsetwnii;
   ...
   <your WHEN-NEW-ITEM-INSTANCE code>
   ...
   else
     setwnii;
   end if;
   The downii, unsetwnii and setwnii are defined as follows.

downii

   FUNCTION downii RETURN boolean IS
   BEGIN
     return(:parameter.wnii = 't');
   END;
   
           unsetwnii
   PROCEDURE unsetwnii IS
   BEGIN
       :parameter.wnii := 'f';
   END;
  

setwnii

   PROCEDURE setwnii IS
   BEGIN
     :parameter.wnii := 't';
   END;

Continue

Part #: A32362


Copyright © 1996 Oracle Corporation. All Rights Reserved.