Shik Mahamood Ali Forms

1

Definition Forms used for presenting and manipulating data can be developed. It is GUI used for developing client server database application. .FMB .FMT .FMX Form Module Binary Form Module Text Form Module Executable

COMPONENTS OF FORMS 1.Form Builder It is used to create a form. The design and layout of data entry screens the creations of event driven PL/SQL code used for data validation and navigate can be done via form builder. 2.Form Compiler It is required to compile the file created in form builder and create a binary file, which can be executable form runtime. 3.Form Runtime It is used to run the complied code created by forms compiler. COMPONENTS OF FORM BUILDER 1. Object Navigator It is hierarchical browsing and editing interface that enables you locate and manipulate application objects quickly and easily. 2.Property Palette It is used set and modify the properties for all objects in form modules. 3.Layout Editor It is graphical design facility for creating and arranging interface items and graphical objects in your application. 4.PL / SQL Editor It is the integrated functionality of oracle procedure builder that exists with in form builder. It provides: Development of Trigger, Procedures, Functions and Packages Development of libraries to hold PL/SQL program unit. FORM MODULE TYPES 1.Form Module It is a collection of objectives such as block, canvas, items and event based PL/SQL code blocks called trigger . 2.Menu Module It is a collection of menu items. It can be main menu or sub menu. 3.PL / SQL Libraries The library module is a collection of PL/SQL function and package stored ion a single library file. This library file is the attached to form / menu modules. All other objects in the form or menu can now access share the collection of PL/SQL functions and procedures. 4.Object Libraries

Shik Mahamood Ali 2 It is a collection of form objects that you can use in other modules. You can create it to store, maintain and distribute standard objects that can be reuse across the entire development organization. 5. Object Group (Form Builder) An object group is a container for a group of objects. You define an object group when you want to package related objects so you can copy or subclass them in another module. OBJECTS OF FORMS 1.Blocks Block is logical owner of items. It provides a mechanism for grouping related items into a functional unit for storing, displaying and manipulating records. 2.Items These are interface objects that present data values to the user or enable the user to interact with the form. 3. Canvas A canvas is the background object upon which interface items appear. 4. Frames Frames are used to arrange items with in a block. 5. Windows Windows contains for all visual objects that make up a form builder application. 6. PL/SQL Code Block It is used for event driven code. That code automatically executes when a specific event occurs. Form Built - ins 1.CLEAR_FORM Causes Form Builder to remove all records from, or flush, the current form, and puts the input focus in the first item of the first block. 2.COMMIT_FORM Causes Form Builder to update data in the database to match data in the form. Form Builder first validates the form, then, for each block in the form, deletes, inserts, and updates to the database, and performs a database commit. As a result of the database commit, the database releases all row and table locks. 3.DEBUG_MODE Toggles debug mode on and off in a menu. When debug mode is on in a menu, Form Builder issues an appropriate message when a menu item command executes. 4. ENTER Validates data in the current validation unit. (The default validation unit is Item.)

5.ERASE Removes an indicated global variable, so that it no longer exists, and releases the memory associated with the global variable. Global always allocate 255 bytes of storage. To ensure

Shik Mahamood Ali 3 that performance is not impacted more than necessary, always erase any global variable when it is no longer needs 6. EXECUTE_TRIGGER EXECUTE_TRIGGER executes an indicated trigger. 7. EXIT_FORM Provides a means to exit a form, confirming commits and specifying rollback action. 8.FIND_FORM Searches the list of forms and returns a form module ID when it finds a valid form with the given name. You must define an appropriately typed variable to accept the return value. Define the variable with a type of Form module. 9. FORM_FAILURE Returns a value that indicates the outcome of the action most recently performed during the current Runform session. Use FORM_FAILURE to test the outcome of a built–in to determine further processing within any trigger. To get the correct results, you must perform the test immediately after the action executes. That is, another action should not occur prior to the test. Example: /* ** Built–in: FORM_FAILURE ** Example: Determine if the most recently executed built–in ** failed. */ BEGIN GO_BLOCK(’Success_Factor’); /* ** If some validation failed and prevented us from leaving ** the current block, then stop executing this trigger. ** ** Generally it is recommended to test ** IF NOT Form_Success THEN ... ** Rather than explicitly testing for FORM_FAILURE */ IF Form_Failure THEN RAISE Form_Trigger_Failure; END IF; END; FORM_FATAL Returns the outcome of the action most recently performed during the current Runform session.

Use FORM_FATAL to test the outcome of a built–in to determine further processing within any trigger. To get the correct results, you must perform the test immediately after the action executes. That is, another action should not occur prior to the test. Example: /* ** Built–in: FORM_FATAL

Shik Mahamood Ali 4 ** Example: Check whether the most–recently executed built–in had a fatal error.*/ BEGIN User_Exit(’Calculate_Line_Integral control.start control.stop’); /* ** If the user exit code returned a fatal error, print a ** message and stop executing this trigger. ** ** Generally it is recommended to test ** ** IF NOT FORM_SUCCESS THEN ... ** ** Rather than explicitly testing for FORM_FATAL IF Form_Fatal THEN Message(’Cannot calculate the Line Integral due to internal error.’); RAISE Form_Trigger_Failure; END IF;

END;

FORM_SUCCESS Returns the outcome of the action most recently performed during the current Runform session. Use FORM_SUCCESS to test the outcome of a built–in to determine further processing within any trigger. To get the correct results, you must perform the test immediately after the action executes. That is, another action should not occur prior to the test. Note: FORM_SUCCESS should not be used to test whether a COMMIT_FORM or POST built–in has succeeded. Because COMMIT_FORM may cause many other triggers to fire, when you evaluate FORM_SUCCESS it may not reflect the status of COMMIT_FORM but of some other, more recently executed built–in. A more accurate technique is to check that the SYSTEM.FORM_STATUS variable is set to ’QUERY’ after the operation is done. Example: /* ** Built–in: FORM_SUCCESS ** Example: Check whether the most–recently executed built–in ** succeeded. BEGIN /* ** Force validation to occur*/ Enter; /* ** If the validation succeeded, then Commit the data. ** */ IF Form_Success THEN Commit; IF :System.Form_Status <> ’QUERY’ THEN Message(’Error prevented Commit’); RAISE Form_Trigger_Failure; END IF; END IF; END; FORMS_DDL FORMS_DDL( statement); Issues dynamic SQL statements at runtime, including server–side PL/SQL and DDL.

. */ Forms_DDL(my_stmt). Example 3: /* ** Built–in: FORMS_DDL ** Example: The statement parameter can be a block ** of dynamically created PL/SQL code. IF NOT Form_Success THEN Message (’Table Creation Failed’).*/ BEGIN Forms_DDL(’create table temp(n NUMBER)’).N LOOP my_stmt := my_stmt||’. Enclose the PL/SQL block in a valid BEGIN/END block structure. ELSE Message (’Table Created’). are not required. ELSE Message (’Table Created’). IF NOT Form_Success THEN Message (’Table Creation Failed’). If you • • • • • If you use FORMS_DDL to execute a valid PL/SQL block: Use semicolons where appropriate.. . BEGIN . COL2. create the table. FOR I in 2. BEGIN my_stmt := ’create table tmp(COL1 NUMBER’. */ DECLARE procname VARCHAR2(30).Shik Mahamood Ali 5 Note: All DDL operations issue an implicit COMMIT and will end the current transaction without allowing Oracle Forms to process any pending changes. Do not end the PL/SQL block with a slash. END IF. Example 2: /* ** Built–in: FORMS_DDL ** Example: The string can be an expression or variable. ** TEMP(COL1. END. END IF. /* ** Now. ** Create a table with n Number columns.. use FORMS_DDL to execute a single DML or DDL statement: Example 1: /* ** Built–in: FORMS_DDL ** Example: The expression can be a string literal. END.. my_stmt := my_stmt||’)’. */ PROCEDURE Create_N_Column_Number_Table (n NUMBER) IS my_stmt VARCHAR2(2000). Line breaks. COLn).COL’||TO_CHAR(i)||’ NUMBER’. END LOOP. while permitted...

END IF. ** A result of zero represents success. END IF. BEGIN IF stmt IS NULL THEN Message (’DO_SQL: Passed a null statement. End. ID_NULL Returns a BOOLEAN value that indicates whether the object ID is available. NEW_FORM . then you can call this built-in to return information about the calling form. ELSE Message (’Employee Maintenance Successful’).’).Shik Mahamood Ali 6 IF :global. END IF . Forms_DDL(’Begin ’|| procname ||’. IF NOT Form_Success THEN Message (’Employee Maintenance Failed’).’). check_for_locks BOOLEAN := TRUE) RETURN NUMBER IS SQL_SUCCESS CONSTANT NUMBER := 0. If your application is a multi-form application. RETURN SQL_SUCCESS. END. END IF. RETURN SQL_SUCCESS. ELSE procname := ’Update_New_Employer’. Example 4: /* ** Built–in: FORMS_DDL ** Example: Issue the SQL statement passed in as an argument. END IF. Forms_DDL(stmt). ELSE RETURN Dbms_Error_Code.’). END. ** and return a number representing the outcome of ** executing the SQL statement.Form_Status = ’CHANGED’ THEN Message (’DO_SQL: Form has outstanding locks pending. */ FUNCTION Do_Sql (stmt VARCHAR2. as well as about the current. GET_FORM_PROPERTY Returns information about the given form. or called form.flag = ’TRUE’ THEN procname := ’Assign_New_Employer’. IF Form_Success THEN RETURN SQL_SUCCESS. IF Check_For_Locks AND :System.

Oracle Forms releases memory (such as database cursors) that the terminated form was using. FULL_ROLLBACK Oracle Forms rolls back all uncommitted changes (including posted changes) that were made during the current Runform session. The data type of the name is CHAR. paramlist_name . NEW_FORM (formmodule_name VARCHAR2. (Post–only mode can occur when your form issues a call to another form while unposted records exist in the calling form. If the calling form had been called by a higher form. and deletes in the form. To avoid losing the locks issued by the calling form. If the parent form was a called form. The calling form is terminated as the parent form. The data type of the ID is PARAMLIST. Specify a parameter list when you want to pass parameters from the calling form to the new form.paramlist_name ) formmodule_name Specifies the formmodule name of the called form. Oracle Forms keeps the higher call active and treats it as a call to the new form. NO_ROLLBACK Oracle Forms exits the current form without rolling back to a savepoint. which means that you retain any locks across a NEW_FORM operation. Oracle Forms runs the new form with the same options as the parent form. You can leave the top level form without performing a rollback.query_mode. Oracle Forms runs the new form with the same Runform options as the parent form. You cannot specify a FULL_ROLLBACK from a form that is running in post–only mode. updates.) query_mode Takes one of the following constants as an argument: NO_QUERY_ONLY Runs the indicated form normally. rollback_mode. paramlist_id Specifies the unique ID Oracle Forms assigns when it creates the parameter list. The locks are still in effect when you regain control from Oracle Forms. QUERY_ONLY Runs the indicated form as a query–only form. Oracle Forms prevents any commit processing in the called form. A parameter list passed to a form via NEW_FORM cannot contain parameters of type DATA_PARAMETER (a pointer to record group). allowing the operator to perform inserts. rollback_mode TO_SAVEPOINT Oracle Forms rolls back all uncommitted changes (including posted changes) to the current form’s savepoint. These locks can also occur when invoking Oracle Forms from an external 3GL program.data_mode.Shik Mahamood Ali 7 Exits the current form and enters the indicated form. The name must be enclosed in single quotes.

updates. allowing the operator to query. data_mode NUMBER. Oracle Forms runs the called form with the same Runform preferences as the parent form. A parameter list passed to a form via NEW_FORM cannot contain parameters of type DATA_PARAMETER (a pointer to record group). The data type of the name is CHAR. HIDE is the default parameter. Parameters: formmodule_name Specifies the formmodule name of the called form. update. CALL_FORM (formmodule_name VARCHAR2. CALL_FORM. display NUMBER. but not to insert. switch_menu NUMBER. The name must be enclosed in single quotes. allowing the operator to perform inserts.Shik Mahamood Ali 8 The name you gave the parameter list object when you defined it. and deletes from within the called form. or delete records. DO_REPLACE Causes Oracle Forms to replace the default menu application of the calling form with the default menu application of the called form. switch_menu Takes one of the following constants as an argument: NO_REPLACE Causes Oracle Forms to keep the default menu application of the calling form active for the called form. paramlist_name VARCHAR2). QUERY_ONLY Causes Oracle Forms to run the indicated form in Query Only mode. Runs an indicated form while keeping the parent form active. query_mode NUMBER. query_mode Takes one of the following constants as an argument: NO_QUERY_ONLY Causes Oracle Forms to run the indicated form in normal mode. The data type of the name is CHAR. display Specify one of the following constants as an argument: HIDE Causes Oracle Forms to clear the calling form from the screen before drawing the called form. NO_HIDE Causes Oracle Forms to display the called form without clearing the calling form from the screen. When the called form is exited Oracle Forms processing resumes in the calling form at the point from which you initiated the call to CALL_FORM. paramlist_id .

. Use the GET_PARAMETER_LIST function to return the ID to a variable of type PARAMLIST. form_name. A COMMIT operation in any form will cause validation and commit processing to occur for all forms running in the same session. activate_mode ACTIVATE Sets focus to the form to make it the active form in the application. NO_ACTIVATE Opens the form but does not set focus to the form.activate_mode. form_name. OPEN_FORM( OPEN_FORM( OPEN_FORM( OPEN_FORM( OPEN_FORM( REPLACE_MENU form_name). that is. paramlist_name The name you gave the parameter list object when you defined it.paramlist_id). paramlist_name Specifies the CHAR name of a parameter list to be passed to the opened form.NO_HIDE. The data type of the name is CHAR.activate_mode.session_mode.session_mode).DO_REPLACE. separate database session should be created for the opened form. paramlist_id Specifies the unique ID that Oracle Forms assigns to the parameter list at the time it is created. SESSION Specifies that a new. form_name Specifies the CHAR name of the form to open. paramlist_id PARAMLIST).paramlist_name).Shik Mahamood Ali 9 Specifies the unique ID Oracle Forms assigns when it creates the parameter list.activate_mode. The data type of the ID is PARAMLIST. Call OPEN_FORM to create multiple–form applications. You can optionally include a parameter list as initial input to the called form. data_mode NUMBER. form_name. Call_Form(’lookcust’. OPEN_FORM Opens the indicated form.session_mode. activate_mode NUMBER. form_name.activate_mode). applications that open more than one form at the same time.QUERY_ONLY). session_mode NUMBER. The current form remains current. OPEN_FORM (form_name VARCHAR2. session_mode NO_SESSION Specifies that the opened form should share the same database session as the current form.

Shik Mahamood Ali 10 Replaces the current menu with the specified menu. NEW QUERY IF :System. SET_FORM_PROPERTY Sets a property of the given form. 2. Syntax: SET_FORM_PROPERTY( formmodule_id. . value). PROCEDURE STORE_FORMNAME IS BEGIN :GLOBAL. The value is always a character string. Indicates that a query is open. SYSTEM. tm_name := Get_Application_Property(TIMER_NAME).CURRENT_FORM represents the name of the form that Form Builder is executing.FORM_STATUS represents the status of the current form. Example 2: /* ** Built–in: GET_APPLICATION_PROPERTY ** Example: Capture the username and password of the ** currently logged–on user. SET_FORM_PROPERTY( formmodule_name.Current_Form. */ PROCEDURE Get_Connect_Info( the_username IN OUT VARCHAR2. END. the_connect IN OUT VARCHAR2) IS BEGIN the_username := Get_Application_Property(USERNAME). END. property. The value of SYSTEM. for use in calling ** another Tool. You must call this built–in once for each value you want to retrieve. Form. the_connect := Get_Application_Property(CONNECT_STRING).Calling_Form := :System.SYSTEM. Description: The GET_APPLICATION_PROPERTY built–in returns information about the current Oracle Forms application. The value can be one of three character strings: CHANGED Indicates that the form contains at least one block with a Changed record. Indicates that the form contains only New records.FORM_STATUS SYSTEM. but does not make the new menu active. property. the_password IN OUT VARCHAR2.System Variables 1. The form contains at least one block with QUERY records and no blocks with CHANGED records.Form_Status = ’CHANGED’THEN Commit_Form. the_password := Get_Application_Property(PASSWORD). value).FORM_STATUS becomes CHANGED only after at least one record in the form has been changed and the associated navigation unit has also changed. REPLACE_MENU also allows you to change the way the menu displays and the role.CURRENT_FORM SYSTEM.

Control Blocks A control block is not associated with the database. QUERY Indicates that the form is currently in fetch processing mode. In addition.Shik Mahamood Ali END IF. displaying and manipulating records. END IF. Clear_Form. insert. meaning that a query is currently being processed. End if. All blocks are either single-record or multi-record blocks: A single-record block displays one record at a time. /* ** When–New–Item–Instance Trigger */ BEGIN IF :System. Data Blocks Data blocks are associated with data (table columns) within a database. views. update. and the items in a control block do not relate to table columns within a database. Data blocks can be based on database tables. or Fetch Processing mode.EMPNO’ and :System. Enter Query. procedures. 2.MODE indicates whether the form is in Normal. Example: Assume that you want Oracle Forms to display an LOV when the operator enters query mode and the input focus is in a particular text item. The following trigger accomplishes that operation.Mode = ’ENTER–QUERY’ THEN IF NOT Show_Lov(’my_lov’) THEN RAISE Form_Trigger_Failure. the association between a data block and the database allows operators to automatically query.Cursor_Item = ’EMP. MODE 11 SYSTEM. Types of Blocks 1. BLOCKS Block is logical owner of items. The value is always a character string. NORMAL Indicates that the form is currently in normal processing mode. SYSTEM. It provides a mechanism for grouping related items into a functional unit for storing. . By default. 3. A multi-record block displays more than one record at a time. ENTER-QUERY Indicates that the form is currently in Enter Query mode. a data block can also be a master or detail block: Master block displays a master record associated with detail records displayed in a detail block. and delete rows within a database. A detail block displays detail records associated with a master record displayed in master block. or transactional triggers. END.

Syntax: GET_BLOCK_PROPERTY( block_id. property). Example: /* ** Built–in: BLOCK_MENU ** Example: Calls up the list of blocks in the form when the ** user clicks a button. GET_BLOCK_PROPERTY( block_name. and flushes the current block without prompting the end user. or "flush. 2. Form Builder sets the input focus to the first enterable item in the block you select from the LOV. IF :System. NO_VALIDATE Form Builder flushes the current block without validating the changes. and prints a message if ** the user chooses a new block out of the list to ** which to navigate. 3. performs a commit. Define the variable with a type of Block. or prompting the end user. COMMIT_MODE The optional action parameter takes the following possible constants as arguments: ASK_COMMIT Form Builder prompts the end user to commit the changes during CLEAR_BLOCK processing. BLOCK_MENU built-in 12 Displays a list of values (LOV) containing the sequence number and names of valid blocks in your form. . CLEAR_BLOCK built-in Causes Form Builder to remove all records from." the current block. END IF.Shik Mahamood Ali Block Built . Clear_Block(No_Validate).ins 1. BEGIN BLOCK_MENU. property).Cursor_Block <> prev_blk THEN Message(’You successfully navigated to a new block!’). committing the changes. You must define an appropriately typed variable to accept the return value. You must issue a call to the built-in once for each property value you want to retrieve. */ DECLARE prev_blk VARCHAR2(40) := :System. GET_BLOCK_PROPERTY Returns information about a specified block. 4. NO_COMMIT Form Builder validates the changes and flushes the current block without performing a commit or prompting the end user. END. FIND_BLOCK Searches the list of valid blocks and returns a unique block ID. DO_COMMIT Form Builder validates the changes.Cursor_Block.

UPDATE_ALLOWED. */ IF NOT Id_Null(blk_id) THEN Set_Block_Property(blk_id. */ PROCEDURE Make_Block_Query_Only( blk_name IN VARCHAR2 ) IS blk_id Block. GO_BLOCK GO_BLOCK navigates to an indicated block.PROPERTY_FALSE). Example: /* ** Built–in: SET_BLOCK_PROPERTY ** Example: Prevent future inserts. 6. Syntax: SET_BLOCK_PROPERTY( block_id.PROPERTY_FALSE).SET_BLOCK_PROPERTY Sets the given block characteristic of the given block. top_rec := Get_Block_Property( bk_id.INSERT_ALLOWED. CURRENT_RECORD). value). ** (2) Current Record which is visible at the ** first (top) line of the multirecord ** block. Set_Block_Property(blk_id. NEXT_BLOCK Navigates to the first navigable item in the next enterable block in the navigation sequence 8. 5. property.PREVIOUS_BLOCK Navigates to the first navigable item in the previous enterable block in the navigation sequence 9. TOP_RECORD). Otherwise signal ** an error. If the target block is non-enterable . an error occurs. SET_BLOCK_PROPERTY( block_name. */ cur_rec := Get_Block_Property( bk_id. and deletes to ** queried records in the block whose name is ** passed as an argument to this procedure. Set_Block_Property(blk_id.DELETE_ALLOWED. /* ** If the block exists (ie the ID is Not NULL) then set ** the three properties for this block. ELSE . value). 7. property. BEGIN /* Lookup the block’s internal ID */ blk_id := Find_Block(blk_name).PROPERTY_FALSE). updates. ID_NULL Returns a BOOLEAN value that indicates whether the object ID is available.Shik Mahamood Ali 13 ** Determine the (1) Current Record the cursor is in.

and Block triggers).System Variables 1. If the current navigation unit is the form (as in the Pre.Item. record. Example: Assume that you want to create a trigger that performs a commit before clearing a block if there are changes to commit within that block.and Post-Form triggers). the value of SYSTEM.CURRENT_BLOCK The value that the SYSTEM. record.and Post. the value of SYSTEM.CURSOR_BLOCK is the name of the block where the cursor is located.’).SYSTEM.Block_Status = ’CHANGED’ THEN Commit_Form. the value of SYSTEM. or item (as in the Pre.CURRENT_BLOCK is the name of the block that Form Builder is processing or that the cursor is in. The following Key–CLRBLK trigger performs this function.Shik Mahamood Ali 14 Message(’Block ’||blk_name||’ does not exist. or item (as in the Pre. Record. The value can be one of three character strings: CHANGED NEW QUERY Indicates that the block contains at least one Changed record. END IF.Item. The value is always a character string.SYSTEM. IF :System. 2.and Post. Indicates that the block contains only New records. the value of SYSTEM.BLOCK_STATUS SYSTEM. or the current data block during trigger processing. Indicates that the block contains only Valid records that have been retrieved from the database. END. Block .CURSOR_BLOCK The value that the SYSTEM.and Post-Form triggers). 3.CURRENT_BLOCK system variable represents depends on the current navigation unit: If the current navigation unit is the block. and Block triggers). If the current navigation unit is the form (as in the Pre. Clear_Block.SYSTEM.CURSOR_BLOCK system variable represents depends on the current navigation unit: If the current navigation unit is the block. Record.BLOCK_STATUS represents the status of a Data block where the cursor is located. RAISE Form_Trigger_Failure. .CURRENT_BLOCK is NULL.CURSOR_BLOCK is NULL. END IF.

DECLARE curblk VARCHAR2(30).TRIGGER_BLOCK represents the name of the block where the cursor was located when the current trigger initially fired. When-Clear-Block.Cursor_Block. ELSIF curblk = ’CUSTOMERS’ THEN Go_Block(’ORDERS’). The value is always a character string. 4. A Detail Block Can Be a Master You can create block relationships in which the detail of one master-detail link is the master for another link. END. and on which master block of a master/detail relation. When-Remove-Record MASTER-DETAIL RELATIONSHIP A master-detail relationship is an association between two data blocks that reflects a primaryforeign key relationship between the database tables on which the two data blocks are based.TRIGGER_BLOCK SYSTEM. and the detail data block is based on the table with the foreign key. A master-detail relationship equates to the one-tomany relationship in the entity relationship diagram.Trigger_Block’)). BEGIN curblk := :System.COORDINATION_OPERATION to help an On-Clear-Details trigger determine what type of coordination-causing operation fired the trigger. SYSTEM. Block – Based Triggers [Block Processing Trigger] When-Create-Record. IF curblk = ’ORDERS’ THEN Go_Block(’ITEMS’). The master data block is based on the table with the primary key.or Post-Form trigger. The following trigger performs this function.CURSOR_BLOCK stored in a local variable. What Is a Relation? .MASTER_BLOCK This system variable works with its companion SYSTEM. Example: Assume that you want to write a form–level procedure that navigates to the block where the cursor was when the current trigger initially fired. END IF.Shik Mahamood Ali Example: 15 Assume that you want to create a Key–NXTBLK trigger at the form level that navigates depending on what the current block is. When-Database-Record. The value is NULL if the current trigger is a Pre. using :SYSTEM. The following statement performs this function. 5. ELSIF curblk = ’ITEMS’ THEN Go_Block(’CUSTOMERS’). SYSTEM. Go_Block(Name_In(’System.

Changing the Master Deletes property from the default of Non-Isolated to Isolated results in the removal of the On-Check-Delete-Master trigger. you can delete all corresponding line items when an order is deleted. Like implicitly created relations. propagate. You can create a relation either: • Implicitly with a master-detail form module • Explicitly in the Object Navigator Implicit Relations When you create a master-detail form module. you can create your own by setting the properties in the New Relation dialog box. For example. Property Use    Non-Isolated Cascading Isolated Prevents the deletion of the master record when the detail records exist Deletes the detail records when a master record is deleted Deletes only the master record What Happens When You Modify a Relation? • • Changing the Master Deletes property from the default of Non-Isolated to Cascading replaces the On-Check-Delete-Master trigger with the Pre. Explicit Relations If a relation is not established when default blocks are created. PL/SQL program units and triggers are created automatically when you explicitly create a relation. Master Deletes You can prevent. S_ORD_S_ITEM. This relation is named masterblock_detailblock.Delete trigger. MASTER DELETES PROPERTY RESULTING TRIGGERS Non-Isolated (the default) On-Check-Delete-Master On-Clear-Details On-Populate-Details Cascading On-Clear-Details On-Populate-Details Pre-Delete Isolated On-Clear-Details On-Populate-Details . for example.Shik Mahamood Ali 16 A relation is a Form Builder object that handles the relationship between two associated blocks. a relation is automatically created. or isolate deletion of a record in a master block when corresponding records exist in the detail block by setting the Master Deletes property.

To fetch the detail records. and lengths from the database columns referenced in the SELECT statement. Join Condition Use to: • • • • • Create links between blocks using SQL Alter links between blocks using SQL Define using: Usual SQL equi-join condition syntax Block names instead of the base table names Item names that exist in the form module instead of base table column names  Master-detail triggers On-Check-Delete-Master. Deferred Without Auto Query When coordination-causing event occurs. Query record groups can be created and modified at design time or at runtime. the detail records are fetched immediately. Static record group . Non-query record group A non-query record group is a group that does not have an associated query. On-Clear-Details RECORD GROUP This object represents an internal Form Builder data structure that has a column/row framework similar to a database table. Auto-Query False) Deferred with Auto Query Oracle Forms defers fetching the associated detail records until the operator navigates to the detail data block. data types. The records in a query record group are the rows retrieved by the query associated with that record group. Default [Immediate] The default setting. Oracle Forms does not automatically fetch the detail records. but whose structure and values can be modified programmatically at runtime. Query record group A query record group is a record group that has an associated SELECT statement. Prevent Masterless Operation Ensures that the detail data block cannot be queried or used to insert records when a master record is not currently displayed. Non-query record groups can be created and modified only at runtime. When a coordination-causing event occurs.Shik Mahamood Ali Coordination 17 You can control how the detail records are displayed when a master block is queried by setting the coordination property. On-Populate-Details. you can defer querying the line items for an order until the operator navigates to the item block. (Deferred False. The columns in a query record group derive their default names. the operator must navigate to the detail data block and explicitly execute a query. For example.

groupcolumn_name VARCHAR2. POPULATE_GROUP returns a 0 (zero). row_number Adds a row to the given record group. scope NUMBER.row_number NUMBER. Sets the value for the record group cell identified by the given row and column. ADD_GROUP_ROW (recordgroup_name VARCHAR2. The record group is cleared and rows that are fetched replace any existing rows in the record group. POPULATE_GROUP_WITH_QUERY (recordgroup_id RecordGroup. .Shik Mahamood Ali 18 A static record group is not associated with a query. The record group has columns representing each column you include in the select list of the query C] DELETE_GROUP (recordgroup_name VARCHAR2). The rows that are retrieved as a result of a successful query replace any rows that exist in the group. NUMBER). DELETE_GROUP_ROW (recordgroup_id RecordGroup. Static record groups can be created and modified only at design time. array_fetch_size NUMBER). Populating Groups: POPULATE_GROUP (recordgroup_id RecordGroup). Upon a successful query. Executes the query associated with the given record group and returns a number indicating success or failure of the query. query VARCHAR2. column_width NUMBER) Adds a column of the specified type to the given record group. When rows are deleted. SET_GROUP_CHAR_CELL(groupcolumn_id GroupColumn. SET_GROUP_DATE_CELL (groupcolumn_id GroupColumn.column_type NUMBER. and they remain fixed at runtime. query VARCHAR2) Populates a record group with the given query. row_number NUMBER) Deletes the indicated row or all rows of the given record group. array_fetch_size NUMBER) Creates a non-query record group with the given name B] CREATE_GROUP_FROM_QUERY (recordgroup_name VARCHAR2. scope NUMBER. cell_value DATE). the appropriate memory is freed and available to Form Builder. you define its structure and row values at design time. An unsuccessful query generates an ORACLE error number that corresponds to the particular SELECT statement failure. Form Builder automatically decrements the row numbers of all rows that follow a deleted row. Creates a record group with the given name. Record Group built-in subprograms Creating and deleting groups: A] CREATE_GROUP (recordgroup_name VARCHAR2.cell_value VARCHAR2) Sets the value for the record group cell identified by the given row and column. Deletes a programmatically created record group. row_number NUMBER. Modifying a group's structure: ADD_GROUP_COLUMN (recordgroup_name VARCHAR2. instead.

A cell is an intersection of a row and column. BEGIN /* ** Make sure the record group does not already exist. gc_id := Add_Group_Column(rg_id. errcode NUMBER. gc_id GroupColumn. Sets the value for the record group cell identified by the given row and column. You must define an appropriately typed variable to accept the return value.cell_value NUMBER). GET_GROUP_DATE_CELL (function) GET_GROUP_NUMBER_CELL (function) Processing rows: GET_GROUP_ROW_COUNT (function) GET_GROUP_SELECTION_COUNT (function) GET_GROUP_SELECTION (function) RESET_GROUP_SELECTION (procedure) SET_GROUP_SELECTION (procedure) UNSET_GROUP_SELECTION (procedure) Object ID functions: FUNCTION FIND_GROUP (recordgroup_name VARCHAR2). Getting cell values: GET_GROUP_CHAR_CELL (groupcolumn_id GroupColumn. /* ** If it does not exist. Define the variable with a type of RecordGroup.Shik Mahamood Ali 19 SET_GROUP_NUMBER_CELL(groupcolumn_id GroupColumn. */ rg_id := Find_Group(rg_name). */ IF Id_Null(rg_id) THEN rg_id := Create_Group(rg_name).*/ DECLARE rg_name VARCHAR2(40) := ’Salary_Range’. END IF. /* ** Populate group with a query . create it and add the two ** necessary columns to it. rg_id RecordGroup. NUMBER_COLUMN). /* Add two number columns to the record group */ gc_id := Add_Group_Column(rg_id. ’Base_Sal_Range’. Returns the VARCHAR2 or LONG value for a record group cell identified by the given row and column. row_number NUMBER. NUMBER_COLUMN). ’Emps_In_Range’. Searches the list of record groups and returns a record group ID when it finds a valid group with the given name. row_number NUMBER). FIND_COLUMN (function) Example: /* ** Built–in: CREATE_GROUP ** Example: Creates a record group and populates its values ** from a query.

or programmatically. LOV [ LIST OF VALUES ] An LOV is a scrollable popup window that provides the end user with either a single or multi-column selection list. RAISE Form_Trigger_Failure.  LOV values that are selected by the end user can be assigned to form items according to the return items you designate.Shik Mahamood Ali 20 */ errcode := Populate_Group_With_Query( rg_id. as long as the input focus is in a text item that has an attached LOV. SHOW_LOV( lov_name.   At design time.COUNT(EMPNO) ’ ||’FROM EMP ’ ||’GROUP BY SAL–MOD(SAL.1000) ’ ||’ORDER BY 1’). Example: /* ** Built–in: SHOW_LOV ** Example: Display a named List of Values (LOV) */ DECLARE a_value_chosen BOOLEAN. The list of values remains displayed until the operator dismisses the LOV or selects a value. LOV Properties . LOV Built-in subprograms 1. BEGIN a_value_chosen := Show_Lov(’my_employee_status_lov’). LOV values are derived from record groups. END. and FALSE if the operator Cancels and dismisses the list. ’SELECT SAL–MOD(SAL.  LOV auto-reduction and search features allow end users to locate specific values. when the end user navigates to a text item with an associated LOV. Default Key for LOV – F9 LOVs provide the following functionality:  LOVs can be displayed by end user request (when an LOV is available).LIST_VALUES LIST_VALUES displays the list of values for the current item.’). SHOW_LOV( lov_id). y). IF NOT a_value_chosen THEN Message(’You have not selected a value.SHOW_LOV Displays a list of values (LOV) window at the given coordinates. END IF. x. 2. x. independent of any specific text item.1000). y). and returns TRUE if the operator selects a value from the list. SHOW_LOV( lov_name). SHOW_LOV( lov_id. an LOV can be attached to one or more text items in the form. Bell.

Column Mapping This property is used to specify the return item.Automatic Select property Specifies what happens when an LOV has been invoked and the user reduces the list to a single choice when using auto-reduction or searching: When Automatic Confirm is set to Yes. 9. When Automatic Skip is set to No. from this value entered the where clause constructed. Long List It is used to append a ‘ where clause ‘ to the select statement.Automatic Refresh property Determines whether Form Builder re-executes the query to populate an LOV that is based on a query record group. the focus remains in the text item after the operator makes a selection from the LOV. 2. Automatic Skip (LOV) property Moves the cursor to the next navigable item when the operator makes a selection from an LOV to a text item. LOV. value NUMBER). the LOV is dismissed automatically and column values from the single row are assigned to their corresponding return items.Automatic Display property Specifies whether Form Builder displays the LOV automatically when the operator or the application navigates into a text item to which the LOV is attached. 11. property 5. SET_LOV_COLUMN_PROPERTY (lov_id NUMBER.Shik Mahamood Ali 21 1. 10. Set_LOV_Property('my_lov'.'new_group'). SET_LOV_COLUMN_PROPERTY Sets the given LOV property for the given LOV. Sets the given LOV property for the given LOV. 7.colnum NUMBER.Validation from Lov to text item.GROUP_NAME. SET_LOV_PROPERTY(lov_id LOV. 4. GET_LOV_PROPERTY (lov_id. 3. When this property is true a dialog box appear. property NUMBER. 8. 12. . the LOV remains displayed. 6.value VARCHAR2).>If it is not specified then value from Lov cannot assigned to the block. LOV for Validation [ Yes / No ] If it is true so that the system check value entered with the list of values Validation from LOV – text item property .GROUP_NAME Specifies the name of the record group on which an LOV is based. When Automatic Confirm is set to No.Title property Specifies the title to be displayed for the object. Returns information about a specified list of values (LOV). In this dialog box any value can be entered. giving the operator the option to explicitly select the remaining choice or dismiss the LOV. property LOV).

Adds parameters to a parameter list. The data type of the key is VARCHAR2. Creates a parameter list with the given name. or the VARCHAR2 name of the parameter list. END IF.id'). The actual parameter can be either a parameter list ID of type PARAMLIST. Parameter – Built Ins 1. is of little value since it merely duplicates default Form Builder functionality. IF :customer.value VARCHAR2). and an associated value. list or name Specifies the parameter list. using a Key-LISTVAL trigger allows you to add subsequent PL/SQL statements that execute after the LOV is displayed. 5. as written. 2. Types 1. The value of the text parameter is a character string.CREATE_PARAMETER_LIST (name VARCHAR2). Data Parameter It is name of the record group present in the current form. key VARCHAR2) Deletes the parameter with the given key from the parameter list. GET_PARAMETER_ATTR (list VARCHAR2. In the following example. Returns the current value and type of an indicated parameter in an indicated parameter list.Shik Mahamood Ali 22 Key-LISTVAL Trigger: List_Values. However. PARAMETER LIST List of Parameter or list that contains parameter names and their values Input values required for a form as startup are provided by parameters. 2. It can also passed between different oracle products. DELETE_PARAMETER (list VARCHAR2.id IS NULL THEN Go_Item ('customer. either by list ID or name. The name of the parameter. key 4. Data type – char – 2555 char maximum Global variables are visible across multiple forms Parameter values are not visible across multiple forms. its type. 3. This trigger. an IF statement is added to the previous trigger: Key-LISTVAL Trigger: List_Values. VARCHAR2).PROCEDURE DESTROY_PARAMETER_LIST (list VARCHAR2) Deletes a dynamically created parameter list and all parameters it contains. But not between forms. paramtype NUMBER. . It is passed between oracle products. but before Form Builder returns to the normal event sequence. Text Parameter It is passed between forms. key VARCHAR2. ADD_PARAMETER (list VARCHAR2. paramtype VARCHAR2. key VARCHAR2. Each parameter consists of a key.

paramtype NUMBER) Sets the type and value of an indicated parameter in an indicated parameter list. The actual parameter you supply must be a variable of type NUMBER. execmode. even if the called application has not completed its display. Valid values are the name of a form module. location. commmode. BOOK specifies Oracle Book.list. the value is the name of a record group. display). key VARCHAR2. The application looks for the module or document in the default paths defined for the called product. execmode. Form Builder returns a message to the end user. or the VARCHAR2 name of the parameter list. Oracle Graphics display. Executing the parameter sets the value of the variable to one of the following numeric constants: DATA_PARAMETER Indicates that the parameter's value is the name of a record group. GRAPHICS specifies Oracle Graphics. SYNCHRONOUS specifies that control returns to Oracle Forms only after the called product has been exited. Syntax: RUN_PRODUCT( product. TEXT_PARAMETER Indicates that the parameter's value is an actual data value. display). document. If the parameter is a text parameter. document Specifies the CHAR name of the document or module to be executed by the called product. Key The VARCHAR2 name of the parameter. The actual parameter can be either a parameter list ID of type PARAMLIST. RUN_PRODUCT( product. document. If the called product is unavailable at the time of the call. Paramtype An OUT parameter of type NUMBER. commmode Specifies the communication mode to be used when running the called product.name. location. ASYNCHRONOUS specifies that control returns to the calling application immediately. RUN_PRODUCT built-in Invokes one of the supported Oracle tools products and specifies the name of the module or module to be run. and cannot be an expression. Valid numeric constants for this parameter are SYNCHRONOUS and ASYNCHRONOUS. REPORTS specifies Oracle Reports. commmode.SET_PARAMETER_ATTR (list PARAMLIST. report. the value is an actual text parameter. . The operator cannot work in the form while the called product is running. product Specifies a numeric constant for the Oracle product you want to invoke: FORMS specifies a Runform session. Value An OUT parameter of type VARCHAR2. If the parameter is a data type parameter. 6.Shik Mahamood Ali 23 list or name Specifies the parameter list to which the parameter is assigned. or Oracle Book document.

Valid numeric constants for this parameter are BATCH and RUNTIME. (This parameter is only required when you are using an Oracle Graphics chart item in a form.item_name. use a variable of type PARAMLIST. Valid values for this parameter are the CHAR name of the parameter list. list or name Specifies the parameter list to be passed to the called product. BEGIN /* ** Check to see if the ’tmpdata’ parameter list exists. /* ** If it does. Example: /* ** Built–in: RUN_PRODUCT ** Example: Call an Oracle Reports 2.) Note: You can pass text parameters to called products in both SYNCHRONOUS and ASYNCHRONOUS mode. passing the ** data in record group ’EMP_RECS’ to substitute ** for the report’s query named ’EMP_QUERY’. location Specifies the location of the document or module you want the called product to execute. Valid constants for this property are FILESYSTEM and DB. ** Presumes the Emp_Recs record group already ** exists and has the same column/data type ** structure as the report’s Emp_Query query. */ pl_id := Get_Parameter_List(’tmpdata’). Data passing is supported only for master queries. To specify a parameter list ID. or NULL. parameter lists that contain parameters of type DATA_PARAMETER (pointers to record groups) can only be passed to Oracle Reports and Oracle Graphics in SYNCHRONOUS mode. display Specifies the CHAR name of the Oracle Forms chart item that will contain the display (such as a pie chart. However. the ID of the parameter list.Shik Mahamood Ali execmode 24 Specifies the execution mode to be used when running the called product. When you run Oracle Forms. The name of the chart item must be specified in the format block_name. execmode can be either BATCH or RUNTIME.5 report. Note: You cannot pass a DATA_PARAMETER to a child query in Oracle Reports. */ PROCEDURE Run_Emp_Report IS pl_id ParamList. always set execmode to RUNTIME. bar chart. or graph) generated by Oracle Graphics. either the file system or the database.) Note: You can prevent Oracle Graphics from logging on by passing a parameter list that includes a parameter with key set to LOGON and value set to NO. When you run Oracle Reports and Oracle Graphics. */ . then delete it before we create it again in ** case it contains parameters that are not useful for our ** purposes here. (SYNCHRONOUS mode is required when invoking Oracle Graphics to return an Oracle Graphics display that will be displayed in a form chart item.

IF NOT Id_Null(pl_id) THEN Add_Parameter(pl_id. */ DECLARE pl_id ParamList. then add a data parameter to ** the list to associate named query ’DEPT_QUERY’ ** with record group ’DEPT_RECORDGROUP’. ELSE Message(’Parameter list ’||pl_name||’ already exists!’). RAISE Form_Trigger_Failure. END IF.’number_of_copies’.’EMP_RECS’). Example: /* ** Built–in: DELETE_PARAMETER ** Example: Remove the ’NUMBER_OF_COPIES’ parameter from the ** already existing ’TEMPDATA’ parameter list. SYNCHRONOUS.TEXT_PARAMETER.FILEYSTEM. END IF. RUNTIME. DATA_PARAMETER. ’dept_recordgroup’). BEGIN pl_id := Get_Parameter_List(pl_name). END.’19’). passing the parameter list */ Run_Product(REPORTS. . Signal an error ** if the list already exists or if creating the ** list fails. END IF. END. and the record group named ** ’EMP_RECS’ in the form. RAISE Form_Trigger_Failure.’EMP_QUERY’.DATA_PARAMETER. */ Add_Parameter(pl_id. NULL). IF Id_Null(pl_id) THEN pl_id := Create_Parameter_List(pl_name). ’empreport’. IF Id_Null(pl_id) THEN Message(’Error creating parameter list ’||pl_name). Add_Parameter(pl_id. pl_id. then ** attempt to create a new list. /* ** Create the ’tmpdata’ parameter list afresh. Example: /* ** Built–in: ADD_PARAMETER ** Example: Add a value parameter to an existing Parameter ** List ’TEMPDATA’. END IF. */ DECLARE pl_id ParamList. */ pl_id := Create_Parameter_List(’tmpdata’). BEGIN pl_id := Get_Parameter_List(’tempdata’). /* ** Run the report synchronously. pl_name VARCHAR2(10) := ’tempdata’. /* ** Add a data parameter to this parameter list that will ** establish the relationship between the named query ** ’EMP_QUERY’ in the report. Example: /* ** Built–in: CREATE_PARAMETER_LIST ** Example: Create a parameter list named ’TEMPDATA’.Shik Mahamood Ali 25 IF NOT Id_Null(pl_id) THEN Destroy_Parameter_List( pl_id ). ’dept_query’. First ** make sure the list does not already exist. END.

–– SYNCHRONOUS. add a text parameter to the parameter ** list to specify the parameter name and its ** value. –– ’rep0058. BEGIN pl_id := Get_Parameter_List(’tempdata’). TEXT_PARAMETER. /* ** If there is a Non–NULL Last Where clause to ** pass. */ IF wc IS NOT NULL THEN Add_Parameter(pl. The The The The The The Product to call name of the report definition communications mode Execution Mode Location of the reports document Handle to the parameter list –– –– –– –– –– Handle to the ParamList Name of Parameter in the Report Type of Parameter String Value for Parameter END. Example: /* ** Built–in: DESTROY_PARAMETER_LIST ** Example: Remove the parameter list ’tempdata’ after first ** checking to see if it exists */ DECLARE pl_id ParamList.Shik Mahamood Ali 26 */ BEGIN Delete_Parameter(’tempdata’. –– FILESYSTEM. IF NOT Id_Null(pl_id) THEN Destroy_Parameter_List(pl_id). Example 2: PROCEDURE Run_Report_For_Last_Query IS pl ParamList. wc VARCHAR2(2000). wc ). /* ** Get the Where Clause from the Last Query ** using a user–defined function */ wc := Last_Where_Clause. END IF. –– BATCH.’number_of_copies’). .rdf’. passing parameters in the ** parameter list. –– pl ). End. END IF. –– /* Delete the parameter list */ Destroy_Parameter_List(pl). */ Run_Product(REPORTS. –– The Where Clause to Pass BEGIN /* ** Create a parameter list for parameter passing */ pl := Create_Parameter_List(’tmp’). ’the_Where_Clause’. END. /* ** Launch the report. In this case the report definition has ** a parameter named ’the_Where_Clause’ that ** it’s expecting.

Copy( cur_val.SYSTEM. or item (as in the Pre.Global Variable Whose value is accessible to trigger and subprograms in any modules – limit – 255 char length 3.MASTER_BLOCK to help an OnClear-Details trigger determine what type of coordination-causing operation fired the trigger. the value of SYSTEM.a’).and PostItem. IF :emp.CURRENT_BLOCK s The value that the SYSTEM. SYSTEM.NAME_IN The NAME_IN function returns the contents of an indicated variable or item.Shik Mahamood Ali 27 Referencing Form Builder items indirectly 1.System Variable It is used to track of runtime status condition.COORDINATION_OPERATION This system variable works with its companion SYSTEM.direct reference IF NAME_IN('emp. COPY(NAME_IN(source). SYSTEM.BLOCK_STATUS SYSTEM. VARIABLES It is used to store values from form items.CURRENT_BLOCK is the name of the block that Form Builder is processing or that the cursor is in. 'Emp. and on which master block of a master/detail relation.indirect reference 2.CURRENT_BLOCK system variable represents depends on the current navigation unit: If the current navigation unit is the block.Local Variables The local variable is PL/SQL variable whose value is only accessible with in the trigger or user named sub Programs 2.BLOCK_STATUS represents the status of a Data block where the cursor is located. The value can be one of three character strings: CHANGED NEW QUERY Indicates Indicates Indicates retrieved that the block contains at least one Changed record. Record. 2.ename = 'smith' -. that the block contains only New records.ename') = 'smith' -.Empno' ). that the block contains only Valid records that have been from the database. or the current data block during trigger processing. destination). . and Block triggers).COPY built-in Copies a value from one item or variable into another item or global variable. 1. record. Destroy global variable System Variable 1. Use the NAME_IN function to get the value of an item without referring to the item directly. erase(‘global. 3. cur_val VARCHAR2(40).

CURRENT_DATETIME SYSTEM. 6.CURSOR_RECORD SYSTEM. SYSTEM.CURRENT_BLOCK is NULL. SYSTEM. and on which master block of a master/detail relation. The form contains at least one block with QUERY records and no blocks with CHANGED records. SYSTEM. SYSTEM.LAST_QUERY represents the query SELECT statement that Form Builder most recently used to populate a block during the current Runform session.MODE indicates whether the form is in Normal. block. 9. The value is a CHAR string in the following format: DD-MON-YYYY HH24:MM:SS 5. The value is always a character string. SYSTEM. SYSTEM. 4. The value is always a character string. 12. Enter Query.MASTER_BLOCK This system variable works with its companion SYSTEM. The value is always a character string.CURRENT_FORM SYSTEM.CURSOR_RECORD represents the number of the record where the cursor is located.LAST_QUERY SYSTEM.COORDINATION_OPERATION to help an On-Clear. .Shik Mahamood Ali 28 If the current navigation unit is the form (as in the Pre. The value can be one of three character strings: CHANGED Indicates that the form contains at least one block with a Changed record. SYSTEM.CURRENT_DATETIME is a variable representing the operating system date.MODE s SYSTEM. The value is always a character string. Indicates that the form contains only New records. SYSTEM.FORM_STATUS becomes CHANGED only after at least one record in the form has been changed and the associated navigation unit has also changed.FORM_STATUS SYSTEM. where the input focus (cursor) is located.CURSOR_VALUE represents the value of the item where the cursor is located.CURRENT_FORM represents the name of the form that Form Builder is executing. The value is always a character string. the value of SYSTEM.Details trigger determine what type of coordination-causing operation fired the trigger. This number represents the record's current physical order in the block's list of records.CURSOR_ITEM represents the name of the block and item. or Fetch Processing mode. 8. SYSTEM. 11.and Post-Form triggers). NEW QUERY 10. The value is always a character string. Indicates that a query is open.CURSOR_VALUE SYSTEM.FORM_STATUS represents the status of the current form. 7. item. The value of SYSTEM.CURSOR_ITEM SYSTEM.

MOUSE_ITEM represents the name of that item as a CHAR value. The value is always a character string.TRIGGER_ITEM SYSTEM.TRIGGER_ITEM represents the item (BLOCK. Indicates that the form is currently in Enter Query mode. Indicates that the record's validation status is Changed and that the record does not exist in the database. then moves the mouse the platform is not a GUI platform. SYSTEM. The value is always a character string.RECORD_STATUS represents the status of the record where the cursor is located. SYSTEM. SYSTEM. b.MOUSE_ITEM is NULL if: the mouse is not in an item the operator presses the left mouse button.    14. There are 2 ways to creating property class a.ITEM) in the scope for which the trigger is currently firing. Indicates that the form is currently in fetch processing mode. 13. An object based on a property class can inherit the settings of any property in the class that is appropriate for that object. SYSTEM. Once you create a property class you can base other objects on it. 16. it represents the item where the cursor was located when the trigger began. Indicates that the record's validation status is New. Object Navigator method. The value is NULL if the current trigger is a Pre. When referenced in a key trigger. The Property Palette is where you set the properties of objects you create in form and menu modules.TRIGGER_BLOCK SYSTEM.Shik Mahamood Ali NORMAL ENTER-QUERY QUERY 29 Indicates that the form is currently in normal processing mode.ITEM1. Indicates that the record's validation status is Valid and that it was retrieved from the database. if the mouse is in Item1 in Block2. SYSTEM.or Post-Form trigger. 15.TRIGGER_BLOCK represents the name of the block where the cursor was located when the current trigger initially fired. For example.MOUSE_ITEM If the mouse is in an item. SYSTEM. PROPERTY CLASS This object is a named object that contains a list of properties and their associated settings. The value can be one of four character strings: CHANGED INSERT NEW QUERY Indicates that a queried record's validation status is Changed.RECORD_STATUS SYSTEM. Property Window method Property class can not be change programmatically. the value for SYSTEM. VISUAL ATTRIBUTES .MOUSE_ITEM is :BLOCK2. meaning that a query is currently being processed.

FORMS60_EDITOR = C:\WINDOWS\NOTEPAD. Form Builder determines its display size and position dynamically based on the size and position of the text item from which the editor was invoked.’v1’). color. Named Setting the Visual Attribute Group property to a named visual attribute defined in the same module specifies that the object should use the attribute settings defined for the named visual attribute. you can apply it to any object in the same module. the individual attribute settings reflect the current system defaults. Font Weight Color and pattern properties: Foreground Color. 2. Font Size. Visual attributes can include the following properties: Font properties: Font Name. Font Width. system editor. A named visual attribute is a separate object in a form or menu module that defines a collection of visual attribute properties. Font Style. Background Color Fill Pattern. and the window manager. For information on environment variables and system editor availability. User-Named Editor A user-named editor has the same text editing functionality as the default editor. 1. Charmode Logical Attribute. Default Setting the Visual Attribute Group property to Default specifies that that the object should be displayed with default color. The actual settings are determined by a combination of factors. including the type of object. and pattern properties that you set for form and menu objects that appear in your application's interface. You create a user-named editor when you want to display the editor programmatically with SHOW_EDITOR. the resource file in use. When Visual Attribute Group is set to Default. System Editor The system editor to be used is defined by the FORMS60_EDITOR environment variable. 3. Visual attribute name is connected to an object by setting visual attribute name property Set_item_property(‘text1’. and font settings. and user-named editor. Custom When the attribute of an objects are changed at design tome. or when you want to specify custom editor attributes such as scroll bar and title. There are three types of editor objects: default editor. refer to the Form Builder documentation for your operating system. much like styles in a word processing program. they are custom VAT 3.EXE 2.Shik Mahamood Ali 30 Visual attributes are the font. EDITOR This object enables the operator to edit text. . pattern. The editor specified must use the ASCII text format. Default Editor Default editor is invoked at runtime. Visual Attribute Types 1.current_record_attribute. Once you create a named visual attribute. White on Black It can be changed dynamically.

IF Get_Menu_Item_Property(mi_id. Use the system editor if the user has ** checked the ”System_Editor” menu item under the ** ”Preferences” menu in our custom menu module. ed_ok BOOLEAN. val. mi_id MenuItem. BEGIN itm_x_pos := Get_Item_Property(:System. /* ** Show the appropriate editor at position (10. Edit_Textitem(x. IF itm_x_pos > 40 THEN . message_in. END IF. ed_ok). val VARCHAR2(32000). END IF. width. IF ed_ok THEN :emp.comments := val. The EDIT_TEXTITEM procedure invokes the editor associated with the current text item in the form (the default editor.Cursor_Item. END. Example: /* ** Built–in: SHOW_EDITOR ** Example: Accept input from the operator in a user–defined ** editor.Shik Mahamood Ali 31 SHOW_EDITOR(editor_name. val. result). y. ed_id := Find_Editor( ed_name ). */ DECLARE itm_x_pos NUMBER. The SHOW_EDITOR procedure displays a user-named editor at the specified display coordinates. */ val := :emp. or the current system editor). ELSE ed_name := ’my_editor1’. y. message_out.14) on the ** screen. a user-named editor. x.X_POS).comments. Example: /* ** Built–in: EDIT_TEXTITEM ** Example: Determine the x–position of the current item ** then bring up the editor either on the left ** side or right side of the screen so as to not ** cover the item on the screen.CHECKED) = ’TRUE’ THEN ed_name := ’system_editor’.SYSTEM_EDITOR’).14. height). */ DECLARE ed_id Editor. Show_Editor( ed_id. SHOW_EDITOR takes message_in and message_out parameters that allow you to pass a text string in to the editor and to get the edited text string back when the operator accepts the editor.comments item ** into the editor and reassign the edited contents if ** ’ed_ok’ returns boolean TRUE. ed_name VARCHAR2(40). BEGIN mi_id := Find_Menu_Item(’PREFERENCES. 10. Pass the contents of the :emp.

property_false). There are two window styles: Document Document Windows Document windows typically display the main canvases and work areas of your application where most data entry. CANVAS 32 Edit_TextItem(1. Dialog . You can create two types of toolbar canvases: horizontal or vertical. Stacked canvases obscure some part of the underlying content canvas.Stacked Canvas A stacked canvas is displayed atop—or stacked on—the content canvas assigned to the current window. END IF. A single form can include any number of windows. and text items. such as check boxes. WINDOW A window is a container for all visual objects that make up a Form Builder application.1.Shik Mahamood Ali ELSE END. 3. You can display more than one stacked canvas in a window at the same time.Toolbar Canvas A toolbar canvas often is used to create toolbars for individual windows. tab canvases are displayed on top of a content canvas. A content canvas is the "base" view that occupies the entire content pane of the window in which it is displayed. Showing and hiding a canvas programmatically SHOW_VIEW('a_stack'). Edit_TextItem(60.Content Canvas The most common canvas type is the content canvas (the default type). visible. While every new form automatically includes a default window named WINDOW1. 1. just under its menu bar.8). Like stacked canvases. There are four types of canvas objects: Content. radio groups. or SET_VIEW_PROPERTY('a_stack'. This object represents a background entity on which you place interface items.8). and data retrieval is performed. while vertical toolbars are displayed along the far left edge of a window. and often are shown and hidden programmatically. Stacked.20. Tab pages (that collectively comprise the tab canvas) each display a subset of the information displayed on the entire tab canvas. Horizontal toolbar canvases are displayed at the top of a window. Horizontal Toolbar. including canvases. You must define at least one content canvas for each window you create. you can create additional windows as needed by inserting them under the Windows node in the Object Navigator. HIDE_VIEW('a_stack').Tab Canvas A tab canvas—made up of one or more tab pages —allows you to group and display a large amount of related information on a single dynamic Form Builder canvas object. or SET_VIEW_PROPERTY('a_stack'. partly obscuring it. property_true). and Vertical Toolbar.20. 2. visible.1. 4.

Trigger . Window Modality 1. On some platforms. When-Window-Closed .Document windows always are displayed within the MDI application window frame. scroll. All other windows in the application are either document windows or dialog windows. Hide on Exit property For a modeless window. and have restricted functionality compared to modeless windows. Use alerts to advise operators of unusual situations or to warn operators who are about to perform an action that might have undesirable or unexpected consequences. 2. When-Window-Deactivated .Shik Mahamood Ali 33 Dialog Windows Dialog windows are free-floating. called the application window. MDI and SDI windows 1. On some platforms. Form Builder also provides support for an SDI root window on Microsoft Windows. END. and end users can navigate freely among them (provided your application logic allows it). 2. you can layer modeless windows so that they appear either in front of or behind other windows. When- .'history'). */ BEGIN Replace_Content_View('employee_status'. view_name VARCHAR2). containers typically used for modal dialogs that require immediate user interaction. modal windows are "always-on-top" windows that cannot be layered behind modeless windows. REPLACE_CONTENT_VIEW (window_name VARCHAR2. ** Built-in: REPLACE_CONTENT_VIEW ** Example: Replace the 'salary' view with the 'history' ** view in the 'employee_status' window.Modal Windows Modal windows are usually used as dialogs. end users cannot resize. for example. Single Document Interface Although MDI is the default system of window management during Forms Runtime. REPLACE_CONTENT_VIEW built-in Replaces the content canvas currently displayed in the indicated window with a different content canvas. . or iconify a modal window. Multiple Document Interface MDI applications display a default parent window. Modeless Windows You can display multiple modeless windows at the same time. On most GUI platforms. Modal windows are often displayed with a platformspecific border unique to modal windows.Windows When-Window-Activated Window-Resized ALERT An alert is a modal window that displays a message notifying the operator of some application condition. determines whether Form Builder hides the window automatically when the end user navigates to an item in another window.

When the given alert is located. Changes the message text for an existing alert. Returns a BOOLEAN value that indicates whether the object ID is available. err_txt ).property VARCHAR2. You define an object group when you want to package related objects so you can copy or subclass them in another module. END. message SHOW_ALERT (alert_id Alert). Displays the given alert.Shik Mahamood Ali 34 There are three styles of alerts: Stop. Caution.button NUMBER. and Note. al_button := Show_Alert( al_id ). property NUMBER. OBJECT GROUPS An object group is a container for a group of objects. Searches the list of valid alerts in Form Builder. You must return the ID to an appropriately typed variable. Message severity is represented visually by a unique icon that displays in the alert window. the subprogram returns an alert ID. alert_message_text. SET_ALERT_PROPERTY (alert_id ALERT. Each style denotes a different level of message severity. FIND_ALERT (alert_name VARCHAR2). and returns a numeric value when the operator selects one of three alert buttons. ** Trigger: On-Error */ DECLARE err_txt VARCHAR2(80) := Error_Text. BEGIN al_id := Find_Alert('My_Error_Alert'). ** Built-in: SET_ALERT_PROPERTY ** Example: Places the error message into a user-defined alert ** named 'My_Error_Alert' and displays the alert. Set_Alert_Property(al_id. SET_ALERT_BUTTON_PROPERTY(alert_id ALERT. value VARCHAR2). Object groups provide a way to bundle objects into higher-level building blocks that can be used in other parts of an application and in subsequent development projects. Changes the label on one of the buttons in an alert. You can use object groups to bundle numerous objects into higher-level building blocks that you can use again in another application. Using Object Groups • Blocks include: Items Item-level triggers Block-level triggers Relations • Object groups cannot include other object groups . ID_NULL (Alert BOOLEAN). VARCHAR2). You define an object group when you want to package related objects for copying or sub classing in another module. al_id Alert. al_button Number. Define the variable with a type of Alert.

and personal standards. object groups. An object library can contain simple objects. Objects can be used as standards (classes) for other objects. and distribute standard and reusable objects. but they are protected against change in the library. Use copying to export the definition of an object to another module. unique version of that object in the target module. store. and program units. by using Object Libraries. and personal standards Simplifies the sharing of reusable components Object libraries are convenient containers of objects for reuse. project. • • • • Is a convenient container of objects for reuse Simplifies reuse in complex environments Supports corporate. for a consistent look and feel • Reuse complex objects such as a Navigator Benefits of the Object Library • Simplifies the sharing and reuse of objects • Provides control and enforcement of standards • Eliminates the need to maintain multiple referenced forms SMARTCLASS . you can rapidly create applications by dragging and dropping predefined objects to your form. Reusing components enables you to: • Apply standards to simple objects. Object libraries simplify the sharing of reusable components. They simplify reuse in complex environments. and they support corporate. such as buttons and items. You can use the Object Library to create. Subclassing Subclassing is an object-oriented term that refers to the following capabilities: • Inheriting the characteristics of a base class (Inheritance) • Overriding properties of the base class (Specialization) OBJECT LIBRARY This object provides an easy method of reusing objects and enforcing standards across the entire development organization. property classes.Shik Mahamood Ali 35 • Deleting: An object group does not affect the objects An object affects the object group Copying an Object Copying an object creates a separate. project. In addition. • Changes made to a copied object in the source module do not affect the copied object in the target module. maintain. Any objects owned by the copied object are also copied.

If you frequently use certain objects as standards. report.PLX PL/SQL Library Module Binary PL/SQL Library Module Text PL/SQL Library Module Executable . A library:  Is produced as a separate module and stored in either a file or the database  Provides a convenient means of storing client-side code and sharing it among applications  Means that a single copy of program units can be used by many form. END. or graphic modules  Supports dynamic loading of program units FUNCTION locate_emp(bind_value IN NUMBER) RETURN VARCHAR2 IS v_ename VARCHAR2(15). such as standard buttons.MMB Menu Module Binary .Shik Mahamood Ali 36 A SmartClass is a special member of an Object Library. BEGIN SELECT ename INTO v_ename FROM emp WHERE empno = bind_value.MMT Menu Module Text . functions.PLD . date items. it can be used to subclass existing objects in a form using the SmartClass option from the right mouse button popup menu. and alerts.menu. you can mark them as SmartClasses by selecting each object in the object library and choosing Object—>SmartClass.PLL . You can mark many different objects that are spread across multiple object libraries as SmartClasses. • Is an object in an object library that is frequently used as a class • Can be applied easily and rapidly to existing objects • Can be defined in many object libraries You can have many SmartClasses of a given object PL/SQL Libraries A library is a collection of PL/SQL program units. Reasons to share objects and code:  Increased productivity  Increased modularity  Decreased maintenance  Maintaining standards . RETURN(v_ename). A single library can contain many program units that can be shared among the Oracle Developer modules and applications that need to use them. Object Library members which are not SmartClasses can only be used to create new objects in form modules into which they are added. and packages. including procedures. Unlike other Object Library members.MMX Menu Module Executable Form Builder Built-in Package .

Shik Mahamood Ali

37

EXEC_SQL Provides built-ins for executing dynamic SQL within PL/SQL procedures

VBX Provides built-ins for controlling and interacting with VBX controls; this package works only in a 16-bit environment and is provided for backward compatibility WEB Provides built-ins for the Web environment OLE2 Provides a PL/SQL API for creating, manipulating, and accessing attributes of OLE2 automation objects SUBPROGRAM A subprogram can be either a procedure or a function. Built-in subprograms are therefore called in two distinct ways: • Built-in procedures: Called as a complete statement in a trigger or program unit with mandatory arguments. • Built-in functions: Called as part of a statement, in a trigger or program unit, at a position where the function’s return value will be used. Again, the function call must include any mandatory arguments. TRIGGER Triggers are blocks of PL/SQL code that are written to perform tasks when a specific event occurs within an application. In effect, a Form Builder trigger is an event-handler written in PL/SQL to augment (or occasionally replace) the default processing behavior. Every trigger has a name, and contains one or more PL/SQL statements. A trigger encapsulates PL/SQL code so that it can be associated with an event and executed and maintained as a distinct object.

Trigger Scope

1.Form Level The trigger belongs to the form and can fire due to events across the entire form. 2.Block Level The trigger belongs to a block and can only fire when this block is the current block. 3.Item Level The trigger belongs to an individual item and can only fore when this item is the current item. Trigger Properties
Execution Style

Execution Hierarchy property Specifies how the current trigger code should execute if there is a trigger with the same name defined at a higher level in the object hierarchy.

Shik Mahamood Ali The following settings are valid for this property:

38

Override Specifies that the current trigger fire instead of any trigger by the same name at any higher scope. This is known as "override parent" behavior. Before Specifies that the current trigger fire before firing the same trigger at the next-higher scope. This is known as "fire before parent" behavior. After Specifies that the current trigger fire after firing the same trigger at the next-higher scope. This is known as "fire after parent" behavior.

What are triggers used for?
           Validate data entry Protect the database from operator errors Limit operator access to specified forms Display related field data by performing table lookups Compare values between fields in the form Calculate field values and display the results of those calculations Perform complex transactions, such as verifying totals Display customized error and information messages to the operator Alter default navigation Display alert boxes Create, initialize, and increment timers

Groups of triggers
GROUP FUNCTION

When-triggers On-triggers Pre- and Post-triggers Key-trigger

Execute in addition to default processing Replace default processing Add processing before or after an event Change default processing assigned to a specific key

Trigger Categories  Block-processing triggers o When-Create-Record o When-Clear-Block o When-Database-Record o When-Remove-Record

Shik Mahamood Ali  Interface event triggers o When-Button-Pressed o When-Checkbox-Changed o When-Image-Activated o When-Image-Pressed o When-Radio-Changed o When-Timer-Expired o When –List-Changed o When –List-Activated o When –Tree-Note-Activated o When –Tree-Note-Expanded o When –Tree-Note-Selected o o o o o Key- [all] When-Window-Activated When-Window-Closed When-Window-Deactivated When-Window-Resized

39

 Master-detail triggers o On-Check-Delete-Master o On-Clear-Details o On-Populate-Details  Message-handling triggers o On-Error o On-Message  Navigational triggers o Pre- and Post- Triggers         o Pre-Form Pre-Block Pre-Record Pre-Text-Item Post-Text-Item Post-Record Post-Block Post-Form

When-New-Instance-Triggers     When-New-Form-Instance When-New-Block-Instance When-New-Record-Instance When-New-Item-Instance

 o o Pre-Query Post-Query

Query-time triggers

Shik Mahamood Ali  Transactional triggers. o o o o o o o o o o o o o o o o o o o On-Count On-Delete. On-Insert. On-Lock. On-Logon. On-Logout. On-Select. On-Update. Post-Database-Commit. Post-Delete. Post-Forms-Commit. Post-Insert. Post – Select. Post-Update. Pre-Commit. Pre-Delete. Pre-Insert. Pre-Select. Pre-Update.

40

 Validation triggers o o When-Validate-Item When-Validate-Record

 Mouse Event Triggers o o o o o o o o When-Custom-Item-Event When-Mouse-Click When-Mouse-Double Click When-Mouse-Down When-Mouse-Enter When-Mouse-Leave When-Mouse-Move When-Mouse-Up

 Key-Fn Trigger o A Key-Fn trigger fires when an operator presses the associated key. o Use Key-Fn triggers to create additional function keys for custom functions.  Calling user-named triggers

TRIGGER CATEGORIES
 A. BLOCK-PROCESSING TRIGGERS Block processing triggers fire in response to events related to record management in a block.

you might want to perform an automatic commit whenever this condition occurs. or data-driven default values that must be specified at runtime. An alternative is to use GET_RECORD_PROPERTY to obtain the record status. Because GET_RECORD_PROPERTY requires reference to a specific record.Due_Date := SYSDATE + :Customer. or navigates to the last record in a set while scrolling down.Shik Mahamood Ali 41 1. stored in a preference table.. 2. When-Database-Record Fires when Form Builder first marks a record as an insert or an update. This generally occurs only when the operator modifies the first item in a record.RECORD_STATUS is unreliable because there is no current record. BEGIN /* ** Default Invoice Due Date based on Customer's ** Net Days Allowed value from the Customer block. When-Create-Record Fires when Form Builder creates a new record. */ OPEN ship_dflt. When-Clear-Block Perform an action whenever Form Builder flushes the current block. For example. when the operator presses the [Insert] key. DECLARE CURSOR ship_dflt IS SELECT val FROM cust_pref WHERE Custid = :Customer. but explicit cursor is more ** efficient. . calculated.Net_Days_Allowed. Fires In • CREATE_RECORD WHEN-CREATE-RECORD TRIGGER This example assigns data-driven or calculated default values without marking the record as changed. /* ** Default the shipping method based on this customers ** preference. and after the operator attempts to navigate out of the item. 3. Form Builder fires this trigger. The When-Clear-Block trigger does not fire when Form Builder clears the current block during the CLEAR_FORM event. That is the trigger fires as soon as Form Builder determines through validation that the record should be processed by the next post or commit as an insert or update. Used For • Perform an action whenever Form Builder attempts to create a new record in a block. Used For • • Use a When-Clear-Block trigger to perform an action every time Form Builder flushes the current block. For example. CLOSE ship_dflt. Fires In • • • CLEAR_BLOCK COUNT_QUERY ENTER_QUERY Clear_Block(No_Validate). END. FETCH ship_dflt INTO :Invoice.Ship_Method. its value is always accurate. the value of SYSTEM.Custid AND pref = 'SHIP'. that is. rather than design time. For example. to set complex. removes all records from the block. */ :Invoice.INTO. We could ** use SELECT.. In a When-Clear-Block trigger.

/* If the Form_Status is not back to 'QUERY' ** following a commit. BEGIN IF :System. END IF. like When-Window-Activated. 1.Form_Status = 'CHANGED' THEN Commit_Form. This example executes a COMMIT_FORM if there are changes in the form.Form_Status <> 'QUERY' THEN Message('Unable to commit order to database. 4. or using the keyboard. or for other item. fire only in response to operator input or manipulation.. to adjust a running total that is being calculated for all of the records displayed in a block. such as When-Button-Pressed. or form level functionality. Fires In • • CLEAR_RECORD DELETE_RECORD B.. END. either with the mouse or through keyboard selection . When-Checkbox-Changed Fires when an operator changes the state of a check box. Perform an action whenever a record is cleared or deleted.Shik Mahamood Ali Used For • • 42 Perform an action whenever Form Builder changes a record's status to Insert or Update. END IF. When-Remove-Record Fires whenever the operator or the application clears or deletes a record. thus indicating that the record should be processed by the next COMMIT_FORM operation Use a When-Database-Record trigger to perform an action every time a record is first marked as an insert or an update. 2.'). */ IF :System. Usage Notes • Use a When-Button-Pressed trigger to perform navigation. For example. then the commit was not successful. Initiate an action when the operator toggles the state of a check box. RAISE Form_Trigger_Failure. can fire in response to both operator input and programmatic control. Others. or using the keyboard.INTERFACE EVENT TRIGGERS Interface event triggers fire in response to events that occur in the form interface. When-Button-Pressed Fires when an operator selects a button. either by clicking with the mouse. Some of these trigger. block. by clicking with a mouse. to calculate text item values.

date_shipped’. the value of the check box item remains as it was before the operator navigated to it. Usage Notes • Use a When-Image-Pressed trigger to perform an action when an operator clicks or double clicks on an image item. When-Image-Activated Initiate an action whenever the operator double-clicks an image item. Fires when an operator uses the mouse to: • Single-click on an image item • Double-click on an image item Note : That When-Image-Activated also fires on a double-click.property_false). Fires when an operator uses the mouse to: •  Single-click on an image item.Update_allowed’. • When an operator clicks in a check box. Note : That When-Image-Pressed also fires on a double-click.order_filled item prevents the date_shipped item from being updated if the user marks the order as filled ( checked on ). then the Date_Shipped item is enabled.If the check box is set off.’STMAST:STIMAGE’). So for all navigation triggers that fire before the When-Checkbox-Changed trigger.Shik Mahamood Ali Usage Notes • 43 Use a When-Checkbox-Changed trigger to initiate a task dependent upon the state of a check box. When-Image-Pressed Initiate an action whenever an operator clicks on an image item. Else Set_Item_Property(‘s_ord. Begin READ_IMAGE_FILE(‘ST_’||TO_CHAR(:STMAST.filled’) then Set_Item_Property(‘s_ord.JPG’. 4. 3. End if. Double-click on an image item.date_shipped’.Update_allowed’. End.’JPG’. The above When_Image_Pressed trigger on the stimage item displays a image of the current student (in the stmast block) when the user clicks the image item. the internal value of that item does not change until navigation is completed successfully. When-Checkbox-Changed Trigger examples This trigger on the :S_ord.property_true).STID)||’. End. the When-Checkbox-Changed trigger is the first trigger to register the changed value of a check box item. Begin If checkbox_checked(‘s_ord. Thus. .

6. this trigger immediately confirms whether the customer has a good or excellent credit rating. In addition. Declare . The display style of a list item is determined by the List Style property. Initiate an action when an operator changes the current radio button selected in a radio group item. not for dropdown lists or combo box style list items. it fires each time the end user enters or modifies entered text. • When-Radio-Changed Trigger examples When the user selects credit as the payment type for an order. For example. or using the keyboard. When no_data_found then Message(‘Invalid Student ‘). (De-selecting a radio button in a radio group sets the radio group value to NULL. When-List-Activated Trigger Fires when an operator double-clicks on an element in a list item that is displayed as a T-list. Populate student name based on the selected student id.Shik Mahamood Ali 44 5. If not. either by clicking with the mouse. Usage Notes • Use a When-Radio-Changed trigger to perform an action depending on the state of a radio group. Thus. the internal value of that item does not change until navigation is completed successfully. 7. When-Radio-Changed Description A fire when an operator selects a different radio button in a radio group. For all navigation triggers that fire before the When-Radio-Changed trigger. then the payment type is set to cash.Changed trigger will not fire if an end user duplicates the item using a key mapped to the DUPLICATE_ITEM built-in. The When-List-Changed trigger is not fired if the value of the list is changed programmatically such as by using the DUPLICATE_ITEM built-in. When-List-Changed Trigger Description Fires when an end user selects a different element in a list item or de-selects the currently selected element. Usage Notes • Use a When-List-Changed trigger to initiate an action when the value of the list is changed directly by the end user. Usage Notes • A When-List-Activated trigger fires only for T-list style list items. operators use this technique in Enter Query mode to exclude a radio group from a query. Begin Exception End. if a When-List-Changed trigger is attached to a combo box style list item. the When-Radio-Changed trigger is the first trigger to register the changed value of a radio group. Select stname into :stname from the stmast where stid=:stid.) When an operator clicks an item in a radio group. or de-selects the currently selected radio button. the When-List. or if the end user causes a procedure to be invoked which changes the value. the value of the radio group remains as it was before the operator navigated to it.

DECLARE timer_id TIMER.' two_minutes NUMBER(6) := (120 * 1000). navigation. call_status NUMBER. You can call GET_APPLICATION_PROPERTY(TIMER_NAME) in a When-Timer-Expired trigger to determine the name of the most recently expired timer. or transaction processing. msg_2 VARCHAR2(80) := 'Move into your close. alert_id := FIND_ALERT('tele_alert'). End if. Usage Notes Timers are created programmatically by calling the CREATE_TIMER built-in procedure. Begin If :s_ord.'. The following example is from a telemarketing application. The message box is displayed each time a repeating timer expires. 8. Initiate an action when a programmatic timer expires.’EXCELLENT’) then :s_ord. in which sales calls are timed. End if. update item values. msg_1 VARCHAR2(80) := 'Wrap up the first phase of your presentation'. message(‘Warning – Customer must pay cash‘). BEGIN :GLOBAL.Shik Mahamood Ali 45 v_credit customer.custid.timer_count := 1 BEGIN timer_id := FIND_TIMER('tele_timer'). When-Timer-Expired Description Fires when a timer expires. If v_credit NOT_IN(‘GOOD’. alert_id ALERT. IF :GLOBAL. msg_3 VARCHAR2(80) := 'Ask for the order or repeat the close. Use a When-Timer-Expired trigger to initiate an event.credit_rate%type. End.payment_type:=’CASH’. • The When-Timer-Expired trigger can not fire during trigger. one_and_half NUMBER(5) := (90 * 1000).timer_count = 1 THEN . and message boxes are displayed to prompt the salesperson through each stage of the call. or perform any task that should occur after a specified interval.payment_type=’CREDIT’ then Select credit_rate into v_credit from customer where custid=:s_ord. • • Fires In • Process Expired Timer When-Timer-Expired Trigger examples Example The following example displays a message box each time a repeating timer expires.

one_and_half.timer_count = 2 THEN Change_Alert_Message(alert_id. ELSIF :GLOBAL.Shik Mahamood Ali 46 Set_Alert_Property(alert_id. call_status := Show_Alert(alert_id). NO_REPEAT). Next_Record. call_status := Show_Alert(alert_id). END IF. two_minutes. msg_1). ALERT_MESSAGE_TEXT. Next_Record. ELSE Set_Timer(timer_id. ELSE Set_Timer(timer_id. Note that on some window managers. ELSE Change_Alert_Message(alert_id. This operation is independent of navigation to an item in the window. ELSIF call_status = ALERT_BUTTON2 THEN :GLOBAL. 9. call_status := Show_Alert(alert_id). END. but window activation can also occur independently of navigation. Usage Notes: Use this trigger to perform the following types of tasks: .timer_count := 0. clicking on its title bar. IF call_status = ALERT_BUTTON1 THEN Delete_Timer(timer_id). ELSIF call_status = ALERT_BUTTON2 THEN :GLOBAL. END IF. msg_3). Next_Record. say. When-Window-Activated Initiate an action whenever an operator or the application activates a window. :GLOBAL. Fires when a window is made the active window. msg_2). NO_CHANGE). This occurs at form startup and whenever a different window is given focus. ELSIF call_status = ALERT_BUTTON2 THEN :GLOBAL. IF call_status = ALERT_BUTTON1 THEN Delete_Timer(timer_id). IF call_status = ALERT_BUTTON1 THEN Delete_Timer(timer_id). END IF. Thus. ELSE Set_Timer(timer_id. END IF. NO_CHANGE. a window can be activated by. NO_CHANGE).timer_count := 0.timer_count = 2. navigating to an item in a different window always activates that window.timer_count := 0.

• You can hide the window that contains the current item. Usage Notes: • Use this trigger to programmatically close a window when the operator issues the window–manager Close command. such as width. It does not fire when a window is iconified. PROPERTY_OFF). or y coordinate. • Enforce navigation to a particular item whenever a window is activated. • You can close a window with the HIDE_WINDOW . • Keep track of the most recently fired window trigger by assigning the value from SYSTEM. when the root window is first drawn. End.EVENT_WINDOW to a variable or global variable. Usage Notes: Use this trigger to perform any one of the following types of tasks: • • • Capture the changed window properties. property).) This trigger also fires at form startup. either by the operator or programmatically.Shik Mahamood Ali 47 • Capture initial settings of window properties. 10 . Example: Begin GET_WINDOW_PROPERTY( window_name. and EXIT_FORM built–in subprograms. Fires when a window is resized. Audit the actions of an operator. When-Window-Deactivated Initiate an action whenever a window is deactivated as a result of another window becoming the active window. Example: The following example of a call to SET_WINDOW_PROPERTY from this trigger closes a window whenever the operator closes it by way of the window manager operation: Set_Window_Property(’window_name’. by way of the GET_WINDOW_PROPERTY built–in.When-Window-Closed Initiate an action whenever an operator closes a window with the window manager's Close command. height. VISIBLE. 11. . SET_WINDOW_PROPERTY. x coordinate. resizing the window programmatically fires the When–Window–Resized trigger. 12. Usage Notes: Use this trigger to audit the state of a window whenever the operator deactivates the window by setting the input focus in another window. (Even if the window is not currently displayed. When-Window-Resized Initiate an action whenever a window is resized. Set input focus in an item on the target window. Fires when an operator deactivates a window by setting the input focus to another window. either by the operator or programmatically through a call to RESIZE_WINDOW or SET_WINDOW_PROPERTY.

Example: /* ** Built–in: RESIZE_WINDOW ** Example: Set Window2 to be the same size as Window1 */ PROCEDURE Make_Same_Size_Win( Window1 VARCHAR2.e. h := Get_Window_Property(wn_id1. i. w := Get_Window_Property(wn_id1. Window2 VARCHAR2) IS wn_id1 Window. h NUMBER. For example. */ wn_id1 := Find_Window(Window1).HEIGHT). w NUMBER. KEY. /* ** Resize Window2 to the same size */ Resize_Window( Window2. w. the trigger fires when operator presses a specific key or key-sequence.Shik Mahamood Ali 48 • Maintain certain visual standards by resetting window size if the window was improperly resized.[ALL] ( KEY TRIGGERS ) Key Triggers have a one-to-one relationship with specific keys. Key Triggers and Function Keys KEY TRIGGER Key–CLRBLK Key–CLRFRM Key–CLRREC Key–COMMIT Key–CQUERY Key–CREREC Key–DELREC Key–DOWN Key–DUP–ITEM Key–DUPREC Key–EDIT Key–ENTQRY Key–EXEQRY Key–EXIT Key–HELP Key–LISTVAL Key–MENU Key–NXTBLK Key–NXT–ITEM Key–NXTKEY Key–NXTREC Key–NXTSET Key–PRINT Key–PRVBLK Key–PRV–ITEM Key–PRVREC Key–SCRDOWN Key–SCRUP ASSOCIATED FUNCTION KEY [Clear Block] [Clear Form] [Clear Record] [Accept] [Count Query Hits] [Insert Record] [Delete Record] [Down] [Duplicate Item] [Duplicate Record] [Edit] [Enter Query] [Execute Query] [Exit] [Help] [List of Values] [Block Menu] [Next Block] [Next Item] [Next Primary Key] [Next Record] [Next Set of Records] [Print] [Previous Block] [Previous Item] [Previous Record] [Scroll Down] [Scroll Up] . BEGIN /* ** Find Window1 and get it’s width and height. h ). END. C. Replace the default function associated with a function key.WIDTH). you can define a Key-EXIT trigger to replace the default functionality of the [Help] key.

KEY-COMMIT TRIGGER AT FORM LEVEL: EMPLOYEES FORM BEGIN IF GET_APPLICATION_PROPERTY( CALLING_FORM ) IS NULL THEN COMMIT_FORM. however. These keys are referred to as Key–F0 through Key–F9. The default master/detail triggers enforce coordination between records in a detail block and the master record in a master block. You can attach Key–Fn triggers to 10 keys or key sequences that normally do not perform any Oracle Forms operations. END. Before you can attach key triggers to these keys. use Key–Others triggers to perform the following tasks: • Disable all keys that are not relevant in a particular situation. 1. Specifically. KEY-EXIT AT FORM LEVEL SET_ALERT_PROPERTY (’question_alert’. END IF. Lock command on the default menu 1. A Key–Others trigger overrides the default behavior of a Runform function key (unless one of the following restrictions apply). A Key–Others trigger is associated with all keys that can have key triggers associated with them but are not currently defined by function key triggers (at any level). When this occurs. END IF. you or the DBA must use Oracle Terminal to map the keys to the appropriate functions.Shik Mahamood Ali Key–UP Key–UPDREC 49 [Up] Equivalent to Record. Key–Others Trigger A Key–Others trigger fires when an operator presses the associated key. Usage Notes: Use Key–Fn triggers to create additional function keys for custom functions. Usage Notes: Use Key–Others triggers to limit an operator’s possible actions. D. On-Check-Delete-Master Fires when Form Builder attempts to delete a record in a block that is a master block in a master/detail relation. . ’Do you really want to leave the form?’).MASTER-DETAIL TRIGGERS Form Builder generates master/detail triggers automatically when a master/detail relation is defined between blocks. 2. • Perform one specific action whenever an operator presses any key. IF SHOW_ALERT (’question_alert’) = ALERT_BUTTON1 THEN EXIT_FORM.Key–Fn Trigger A Key–Fn trigger fires when an operator presses the associated key. KEY-DELREC TRIGGER ON S_CUSTOMER BLOCK DELETE_RECORD. ELSE POST. Oracle Forms still displays the function key’s default entry in the Show Keys screen. ALERT_MESSAGE_TEXT.

E. On-Clear-Details Fires when Form Builder needs to clear records in a block that is a detail block in a master/detail relation because those records no longer correspond to the current record in the master block. 3. Usage Notes: Oracle Forms creates the On–Clear–Details trigger automatically when you define a master– detail block relation. Usage Notes Use an On–Error trigger for the following purposes: • • To trap and recover from an error To replace a standard error message with a custom message Use the ERROR_CODE.Shik Mahamood Ali 50 DECLARE the_sum NUMBER. • When Immediate coordination is set. Immediate coordination is the default. this causes the details of the instantiated master to be populated immediately. On-Populate-Details Fires when Form Builder needs to fetch records into a block that is the detail block in a master/detail relation so that detail records are synchronized with the current record in the master block. 2. DBMS_ERROR_TEXT.MESSAGE-HANDLING TRIGGERS Form Builder automatically issues appropriate error and informational messages in response to runtime events. IF the_sum <> :purchase_order. BEGIN SELECT SUM(dollar_amt) INTO the_sum FROM po_distribution WHERE po_number = :purchase_order.number. or to trap and recover from an error. ERROR_TEXT. Oracle Forms marks the blocks as needing to be coordinated. • When Deferred coordination is set and this trigger fires. Usage Notes: • Use an On–Populate–Details trigger when you have established a master–detail relationship and you want to replace the default populate phase of a query. • Example: . • If you intend to manage block coordination yourself. In most cases.’). On-Error Replace a default error message with a custom error message. ERROR_TYPE. END. rather than to a block or item. Trapping certain errors at the block or item level can be difficult if these errors occur while Oracle Forms is performing internal navigation. Message handling triggers fire in response to these default messaging events. such as during a Commit process. 1. RAISE Form_Trigger_Failure. On–Error triggers should be attached to the form.total THEN Message(’PO Distributions do not reconcile. END IF. or DBMS_ERROR_CODE built–in function in an On–Error trigger to identify a specific error condition. you can call the SET_BLOCK_PROPERTY(COORDINATION_STATUS) built–in.

.. lv_errcod NUMBER := MESSAGE_CODE. END IF. BEGIN IF (lv_errcod = 40nnn) THEN /* ** Perform some tasks here */ ELSIF (lv_errcod = 40mmm) THEN /* ** More tasks here */ . RAISE Form_Trigger_Failure. Usage Notes: Use an On–Message trigger for the following purposes: • To trap and respond to an informative message • To replace a standard informative message with a custom message • To exclude an inappropriate message Example: The following example responds to an error message by displaying an alert that gives the user a message and gives the user the choice to continue or to stop: DECLARE alert_button NUMBER. RAISE Form_Trigger_Failure.. END.. BEGIN IF lv_errcod = 40350 THEN alert_button := Show_Alert(’continue_alert’). 2. END IF. for example. lv_errtxt VARCHAR2(80) := MESSAGE_TEXT. lv_errtyp VARCHAR2(3) := ERROR_TYPE.. ELSE . lv_errtxt VARCHAR2(80) := ERROR_TEXT. DECLARE lv_errcod NUMBER := ERROR_CODE. On-Message To trap and respond to a message.. END. ELSIF (lv_errcod = 40zzz) THEN ** More tasks here */ ELSE Message(lv_errtyp||’–’||to_char(lv_errcod)||’: ’||lv_errtxt). lv_errtype VARCHAR2(3) := MESSAGE_TYPE. END IF.Shik Mahamood Ali 51 The following example checks specific error message codes and responds appropriately. IF alert_button = ALERT_BUTTON1 THEN .. ELSE Message(lv_errtyp||’–’||to_char(lv_errcod)||’: ’||lv_errtxt). to replace a default message issued by Form Builder with a custom message.

lineitem_count FROM S_ITEM WHERE ord_id = :S_ORD. Fires once for each record fetched into the block. or Date Shipped.’). This Post-Query trigger on the S_ORD block selects the total count of line items for the current Order. Date Ordered. END IF. just before sending the SELECT statement to the database.Ename IS NULL AND :Employee. This prevents attempts at very large queries. Use Post-Query as follows: • To populate non database items as records are returned from a query • To calculate statistics • A Post-Query trigger fires as each record is fetched (except array processing). Pre-Query Validate the current query criteria or provide additional query criteria programmatically. Use it to check or modify query conditions. ] IF nvl(:control. Post-Query Perform an action after fetching a record.exact_match. Begin End. Use it to perform calculations and populate additional items.name || ‘%’. 2. Note that the trigger only fires on the initial fetch of a record not when a record is subsequently scrolled back into view a second or third time. END IF.QUERY-TIME TRIGGERS 52 Query-time triggers fire just before and just after the operator or the application executes a query in a block. otherwise fail the query with a helpful message A] IF :Employee. [ Set the initial value property to “Y”. B] [ exact_match – Check Box User can specify if or not a query condition for a customer name should exactly match the table value.id. and displays this number as a summary value in the non base table item :Lineitem_count. This trigger is defined at block level or above.Shik Mahamood Ali F. . • To test the operator’s query conditions. This Pre-Query trigger on the S_ORD block only permits queries if there is a restriction on either the Order ID. such as looking up values in other tables based on a value in the current record.Mgr IS NULL THEN Message(’Supply Employee Name and/or Manager Id ’||’for Query. 1.’Y’)=’N’ then :S_Customer. Post-Query fires for each record that is fetched into the block as a result of a query. and to fail the query process if the conditions are not satisfactory for the application • To add criteria for the query by assigning values to base table items • A Pre-Query trigger fires before a query executes. Make sure the user has given one of the two Columns which we have indexed in their search criteria.name:=’%’||:S_customer. RAISE Form_Trigger_Failure. SELECT COUNT(ord_id) INTO :S_ORD.

*/ OPEN lookup_area. FETCH lookup_payplan INTO :Employee. Use it to check or modify query conditions. navigational events occur as Form Builder moves the input focus from the current item to the target item. A Post-Query trigger fires as each record is fetched (except array processing). . POST-QUERY fires 10 times. ** Use Explicit Cursor for highest efficiency. I ] PRE.Shik Mahamood Ali 53 Example: This example retrieves descriptions for code fields. G. but before the statement is actually issued. END. CURSOR lookup_area IS SELECT Area_Name FROM Zip_Code WHERE Zip = :Employee. • • A Pre-Query trigger fires before a query executes. BEGIN /* Lookup the Payment Plan Description given the Payplan_Id in the Employee Record just fetched. Pre-query trigger fires before pre-select trigger. for display in non–database items in the current block. when the operator clicks on a text item in another block.Payplan_Desc_Nondb.Zip. DECLARE CURSOR lookup_payplan IS SELECT Payplan_Desc FROM Payplan WHERE Payplan_Id = :Employee.Payplan_Id.NAVIGATIONAL TRIGGERS Navigational triggers fire in response to navigational events.AND POST. /* ** Lookup Area Descript given the Zipcode in ** the Employee Record just fetched. The pre-query trigger fires just before oracle forms issues the select statement to the database after the operator as define the example records by entering the query criteria in enter query mode. CLOSE lookup_area. FETCH lookup_area INTO :Employee. Use it to perform calculations and populate additional items.TRIGGERS Fire as Form Builder navigates internally through different levels of the object hierarchy. Use Explicit ** Cursor for highest efficiency. What is a difference between pre-select and pre-query? Fires during the execute query and count query processing after oracle forms constructs the select statement to be issued.*/ OPEN lookup_payplan. CLOSE lookup_payplan.Area_Desc_Nondb. For instance. A query fetched 10 records How many times does a PRE-QUERY Trigger and POST-QUERY Trigger will get executed? PRE-QUERY fires once.

IS_ROLE_ENABLED(’TECHNICAL’) THEN MESSAGE(’You are not authorized to run this application’). What Happens When a Navigation Trigger Fails? If a Pre. For instance. Pre-Form Perform an action just before Form Builder navigates to the form from "outside" the form.and Post-Text-Item triggers do not fire. Example The Pre-Text-Item trigger fires just before entering a text item. that is just before entry to or just after exit from the object specified as part of the trigger name. When Do Navigation Triggers Not Fire? The Pre. IF not (DBMS_SESSION. if the validation unit is Record.and Post.and Post.and Post-Navigation Triggers Fire? The Pre. it appears that the input focus has not moved at all.navigation triggers fire during navigation. the input focus returns to its initial location (where it was prior to the trigger firing).or Post navigation trigger fails. Pre.IS_ROLE_ENABLED(’ADMINISTRATIVE’) or (DBMS_SESSION. such as at form startup.navigation triggers do not fire if they belong to a unit that is smaller than the current validation unit. .Shik Mahamood Ali 54 When Do Pre. 1. To the user.

Post-Form Perform an action before Form Builder navigates to "outside" the form. Usage Notes: . property_false). • Use a Pre–Record trigger to keep a running total. RAISE form_trigger_failure. and • store that value in a global variable or form parameter. 3. 4. 5.Shik Mahamood Ali PAUSE. SET_ITEM_PROPERTY(’CONTROL. Pre-Text-Item Perform an action before Form Builder navigates to a text item from the record level.RECORD_STATUS evaluating to NEW. Fires during the Leave the Form process. The following trigger prevents the user from entering a new record given some dynamic condition and the status of SYSTEM. during navigation to a different record. during navigation from one block to another. such as when exiting the form. IF (( dynamic–condition) AND :System. Pre-Record Perform an action before Form Builder navigates to the record level from the block level. enabled. END IF. END IF.stock_button’. 55 2. Usage Notes: • Fires during the Enter the Record process. when a form is exited. Usage Notes: Use a Pre–Text–Item trigger to perform the following types of tasks: • Derive a complex default value. based on other items previously entered into the same record. Usage Notes: Use a Pre–Block trigger to: • Allow or disallow access to a block • Set variable values Disabling stock_button when leaving CONTROL block: begin End. Pre-Block Perform an action before Form Builder navigates to the block level from the form level. Record the current value of the text item for future reference.Record_Status = ’NEW’) THEN RAISE Form_Trigger_Failure. Fires during the Enter the Block process.

use a Post–Form trigger to erase any global variables that the form no longer requires. 7. Usage Notes: Use a Post–Record trigger when you want to perform an action whenever the operator or the application moves the input focus from one record to another.cmdsave’. • To display a message to the operator upon form exit. if validation fails in the form. Fires during the Leave the Record process. lst_itm VARCHAR2(80). the Post–Record trigger fires whenever the operator or the application moves the input focus from one record to another. BEGIN lst_itm := cur_blk||’. Post-Block Manipulate the current record when Form Builder leaves a block and navigates to the form level. that is. etc. IF cur_itm = lst_itm THEN Next_Record. Set_item_property (‘control. For example. Usage Notes: • • Use a Post–Block trigger to validate the block’s current record. for example. cur_blk VARCHAR2(80) := :System. enabled. if you want to set a visual attribute for an item as the operator scrolls down through a set of records. ELSE Next_Item. the record that had input focus when the Leave the Block event occurred. This trigger does not fire when the form is exited abnormally. Example .’||Get_Block_Property(cur_blk. For example. NEXT_BLOCK. Post-Record Manipulate a record when Form Builder leaves a record and navigates to the block level. DELETE_RECORD.LAST_ITEM). The Leave the Record process can occur as a result of numerous operations. CREATE_RECORD. Specifically. PREVIOUS_BLOCK.Shik Mahamood Ali 56 You can use a Post–Form trigger for the following tasks: • To clean up the form before exiting. then skip to the next record instead of ** the default of going back to the first item in ** the same block ** Trigger: Key–Next–Item */ DECLARE cur_itm VARCHAR2(80) := :System.Cursor_Item. you can do so from within this trigger. including INSERT_RECORD. NEXT_RECORD.Cursor_Block. Example: /* ** Built–in: NEXT_RECORD ** Example: If the current item is the last item in the ** block. 6. You might also use this trigger to test a condition and prevent the user from leaving a block based on that condition. property_false).

DEFAULT_WHERE.where_cls). when the form returns to a quiet state to wait for operator input. EXECUTE_QUERY. END.WIDTH). 1d.HEIGHT). EXECUTE_QUERY. Specifically. II] WHEN-NEW-INSTANCE-TRIGGERS Fire at the end of a navigational sequence that places the input focus on a different item. 57 8.where_cls’). :GLOBAL. when the ORDERS form is run. 1. SET_BLOCK_PROPERTY(’prod_lov_blk’. BEGIN DEFAULT_VALUE(’’.Shik Mahamood Ali END IF. Example The When-New-Item-Instance trigger fires immediately after navigation to a new instance of an item.“object”-Instance Triggers Fire? The When-New-”object”-Instance triggers fire immediately after navigation to the object specified as part of the trigger name. :GLOBAL.width_win_order := GET_WINDOW_PROPERTY(’win_order’. :GLOBAL. ’'GLOBAL.height_win_inventory := GET_WINDOW_PROPERTY(’win_inventory’. END.height_win_order := GET_WINDOW_PROPERTY(’win_order’. Fires during the Leave the Item process for a text item. When-New-Form-Instance Trigger at Form Level . by including the following code in your When-New-Form-Instance trigger: 1a.:GLOBAL. END. Specifically. 1b.width_win_inventory := GET_WINDOW_PROPERTY(’win_inventory’. Perform a query of all orders. :GLOBAL. Post-Text-Item Manipulate an item when Form Builder leaves a text item and navigates to the record level. WIDTH). 1c. BEGIN EXECUTE_QUERY.HEIGHT). these triggers fire just after Form Builder moves the input focus to a different item. When-New-Form-Instance Perform an action at form start-up. When Do When-New. this trigger fires when the input focus moves from a text item to any other item. (Occurs after the Pre-Form trigger fires).

When-New-Record-Instance Perform an action immediately after the input focus moves to an item in a different record. when an operator presses [Down] to scroll through a set of records. BEGIN htree := Find_Item('tree_block. SET_WINDOW_PROPERTY( forms_mdi_window. The example locates the hierarchical tree first. For example. each time Oracle Forms instantiates a new record in the block. Ftree. Example The following example of a When-New-Block-Instance trigger conditionally sets the DELETE ALLOWED property to FALSE. IF GET_APPLICATION_PROPERTY(username) = ’SCOTT’ THEN SET_BLOCK_PROPERTY(’S_ITEM’. END IF. WINDOW_STATE. Oracle Forms fires this trigger each time the input focus moves to the next record. rg_emps). to_char(empno) ’ ||' from emp ' ||'connect by prior empno = mgr ' ||’start with job = ’’PRESIDENT’’’). Example This code could be used in a WHEN-NEW-FORM-INSTANCE trigger to initially populate the hierarchical tree with data. TITLE. END. level. DECLARE htree ITEM. but before the When-New-Item-Instance trigger. 2.Shik Mahamood Ali 58 BEGIN SET_WINDOW_PROPERTY( forms_mdi_window.Set_Tree_Property(htree. Ftree. a record group is created and the hierarchical tree is populated. if one exists . ’Summit Sporting Goods Application’). rg_emps RECORDGROUP. and populates the product_image item with a picture of the products. Then. NULL. Example The Cursor arrives in each record of the S_Item block. Usage Notes: Use a When–New–Record–Instance trigger to perform an action every time Oracle Forms instantiates a new record. MAXIMIZE ). in other words. v_ignore := Populate_Group(rg_emps).DELETE_ALLOWED. Usage Notes: Use a When–New–Block–Instance trigger to perform an action every time Oracle Forms instantiates a new block. When-New-Block-Instance Perform an action immediately after the input focus moves to an item in a block other than the block that previously had input focus. END. 3.htree3').’select 1. rg_emps := Create_Group_From_Query('rg_emps'. fires after the When-New-Block-Instance trigger. If the new record is in a different block. v_ignore NUMBER. PROPERTY_FALSE). ename.RECORD_GROUP.

Message(’This date must be of the form 01–MON–YY’). 3.’tiff’. 4.PRODUCT_ID).product_image’). 2] 1.When-New-Item-Instance Fires when the input focus moves to an item. If the new item is in a different block. End if End. END IF.] BEGIN IF (:global.cancel_query = 'Y' and :system. Call_Form(’clerk_timesheet’). END IF. it fires after navigation to an item. Specifically.date_shipped’).’DD’) <> ’01’ THEN Clear_Item. :global. END IF. when Form Builder is ready to accept input in an item that is different than the item that previously had input focus. If Filename= ‘ No file’ then Null. fires after the When-New-Block-Instance trigger. BEGIN IF TO_CHAR(:Emp. 1] IF CHECKBOX_CHECKED(’S_ORD. BEGIN IF :Emp.Hiredate.mode = 'ENTER-QUERY') THEN Exit_Form.order_filled’)THEN SET_ITEM_PROPERTY(’S_ORD. Usage Notes Use a When-New-Item-Instance trigger to perform an action whenever an item gets input focus.date_shipped’.Job = ’CLERK’ THEN Break. Else Read_Image_File(filename. GO_ITEM(’S_ORD. 3].a Example: Brings up the debugging window for a particular ** value of the ’JOB’ item anytime the user changes records. Begin Filename:=get_product_image(:S_ITEM.Empno IS NOT NULL THEN . Perform an action immediately after the input focus moves to a different item. property_true). END. END IF.UPDATE_ALLOWED.cancel_query = 'N'.Example: Clear the current item if it does not represent ** the first day of a month.*/ BEGIN IF :Emp. END.’S_ITEM.Shik Mahamood Ali 59 1] Declare Filename varchar2(20). 2] Built–in: CLEAR_ITEM . The When-New-Item-Instance trigger is especially useful for calling restricted (navigational) built-ins. Break. END.

then the status of each item in the record is checked. These checks are carried out before firing any When-Validate-Item triggers that you have defined. When the record passes these checks. and a When-Validate-Record trigger is then fired. If an item has been changed and is not yet marked as valid. Form Builder performs validation checks during navigation that occurs in response to operator input. such as a Commit operation. then control is passed back to the appropriate level.Range (Lowest-Highest Allowed Value) . then all records in the form are validated. • Validation happens when: – [Enter] Key or ENTER built-in is activated – Control leaves the validation unit due to navigation or commit Validation Process Form Builder performs a validation process at several levels to ensure that records and individual values follow appropriate rules.Cursor_Item = ’EMP. if you commit (save) changes in the form. If not. and form levels. END IF. VALIDATION TRIGGERS Validation triggers fire when Form Builder validates data in an item or record. If validation fails. BEGIN THEN IF :System. unless you have suppressed this action. all records below that level are validated. Clear_Block(No_Validate). Assume that you want Oracle Forms to display an LOV when the operator enters query mode and the input focus is in a particular text item.Data type . Validation occurs at: • Item level: Form Builder records a status for each item to determine whether it is currently valid. then is the item null?) . or default processing.Employee_Id := :Emp. programmatic control. • Block and form level: At block or form level. Validation occurs at item.Mode = ’ENTER–QUERY’ IF NOT Show_Lov(’my_lov’) THEN RAISE Form_Trigger_Failure. For example. Standard checks include the following: . END IF. The following trigger accomplishes that operation.Required (if so. 4].Empno. record.EMPNO’ and :System.Validate from List (see later in this lesson) • Record level: After leaving a record. END. When Does Validation Occur? Form Builder carries out validation for the validation unit under the following conditions: . End if. then Form Builder first performs standard validation checks to ensure that the value conforms to the item’s properties.Shik Mahamood Ali 60 :Global. END. if present.Format mask . so that the operator can make corrections. block. it is set to valid. Form Builder checks to see whether the record is valid. H.

Usage Notes • Use a When-Validate-Item trigger to supplement Form Builder default item validation processing. Validation Triggers • Item level When-Validate-Item • Block level When-Validate-Record 1. it fires as the last part of item validation for items with the New or Changed validation status. and processing continues normally. • If no match is found. but is a partial value of the LOV value. validation succeeds. • The operator or a trigger navigates out of the validation unit. When-Validate-Item Trigger You have already used this trigger to add item-level validation. the LOV is not displayed. The item then passes this validation phase. you can optionally use the LOV contents to validate data entered in the item. Setting the Defer_Required_Enforcement property to Yes allows the operator to move freely among the items in the record. depending on the circumstances: • If the value in the text item matches one of the values in the first column of the LOV. then the full LOV contents are displayed to the operator. but can also be set to record. • It is possible to write a When-Validate-Item trigger that changes the value of an item that Form Builder is validating. Specifically. by default Form Builder will not allow navigation out of the item until a valid value is entered. Using LOVs for Validation When you attach an LOV to a text item by setting the LOV property of the item. • If the item’s value causes a single record to be found in the LOV. This includes when changes are committed. it does make it possible for your application to commit an invalid value to the database. The following events then occur. Form Builder marks the changed item as Valid and does not re-validate it. At validation time. When an item has the Required property set to Yes. Form Builder displays the LOV and uses the text item value as the search criteria to automatically reduce the list. and input focus is returned to the item if the trigger fails. block. or form by the designer. The default validation unit is item. so that the operator must choose.Shik Mahamood Ali 61 • The [Enter] key is (ENTER command is not necessary mapped to the key that is physically labeled Enter) pressed or the ENTER built-in procedure is run (whose purpose is to force validation immediately). then the full LOV column value is returned to the item (providing that the item is defined as the return item in the LOV). When – Validate -Item Fires during the Validate the Item process. If validation succeeds. Example . • The Defer_Required_Enforcement property postpones enforcement of the Required property from item validation to record validation. While this behavior is necessary to avoid validation loops. • If the item value causes multiple records to be found in the LOV. Form Builder then automatically uses the item value as a non case-sensitive search string on the LOV contents. Do this by setting the Validate from List property to Yes for the item. The validation unit is discussed in the next section. The trigger fires after standard item validation.

Specifically.Commplan_Desc FROM commplan WHERE commcode = :Employee.INTO statement must return an error if more than one row is retrieved that matches the criteria. Use <List> for help').Data_Found THEN Message('Invalid Commission Plan. EXCEPTION WHEN No.End_Date THEN Message('Your date range ends before it starts!'). Note that it is possible to write a When-Validate-Record trigger that changes the value of an item in the record that Form Builder is validating.*/ BEGIN IF :Experiment. Since these two text items have values that are related. 2. If validation succeeds. While this behavior is necessary to avoid validation loops. when the operator has left a new or changed record.Commcode. RAISE Form_Trigger_Failure. you can use this trigger to perform additional checks that may involve more than one of the record’s items. in the order they were entered. This code presumes both date items are mandatory and that neither will be NULL. Duplicate entries in COMMPLAN table!'). /* Method 1: Hardcode the item names into the trigger. This implies PL/SQL may attempt to fetch data twice from the table in question to insure that there aren't two matching rows. it does make it possible for your application to commit an invalid value to the database. it fires as the last part of record validation for records with the New or Changed validation status. I. RAISE Form_Trigger_Failure. When-Validate-Record must be defined at block level or above. END. END IF. Form Builder marks the record and all of the fields as Valid and does not re-validate. ** Structured this way. When – Validate -Record Fires during the Validate the Record process.. Example The following example verifies that Start_Date is less than End_Date. rather than check each item separately. RAISE Form_Trigger_Failure. Use a When-Validate-Record trigger to supplement Form Builder default record validation processing. Because Form Builder has already checked that required items for the record are valid.Start_Date > :Experiment. When-Validate-Record Trigger This trigger fires after standard record-level validation.. WHEN Too_Many_Rows THEN Message('Error. BEGIN SELECT description INTO :Employee.TRANSACTIONAL TRIGGERS Transactional triggers fire in response to a wide variety of events that occur as a form interacts with the data source. Transaction processing includes two phases: • Post: – Writes record changes to base tables – Fires transactional triggers • Commit: Performs database commit . the chance this code will ** be reusable in other forms we write is pretty low because of dependency on block and item ** names. END. it's more convenient to check the combination of them once at the record level.Shik Mahamood Ali 62 The SELECT.

. For all inserted or updated records of the block in sequential order: If it is an inserted record: . Commit Triggers Uses 1. implement foreign-key delete rule Fires during the Post and Commit Transactions process. anytime a database commit is going to occur.Shik Mahamood Ali Errors result in: • Rollback of the database changes • Error message The Commit Sequence of Events 63 The commit sequence of events (when the Array DML size is 1) is as follows: 1 Validate the form. even if there are no changes to post. .Check the record uniqueness. For all deleted records of the block (in reverse order of deletion): . Usage Notes • Use a Pre-Delete trigger to delete the detail record of a master record. . It fires once for each record that is marked for delete.Fire the Pre-Insert trigger. Pre-Delete Journaling. 5 Fire the Post-Forms-Commit trigger.Fire the Post-Delete trigger.Insert the row into the base table or fire the On-Insert trigger. If the current operation is COMMIT. before base table blocks are processed. .Copy Value From Item. If it is an updated record: Fire the Pre-Update trigger. Check the record uniqueness Update the row in the base table or fire the On-Update trigger.Fire the Pre-Delete trigger.Fire the Post-Insert trigger. before a row is deleted. Pre-Commit Check user authorization. such as setting up special locking requirements. Fire the Post-Update trigger. .Delete the row from the base table or fire the On-Delete trigger. 7 Fire the Post-Database-Commit trigger. fires if there are changes to base table items in the form or if changes have been posted but not yet committed (This trigger always fires in case of uncommitted posts. 4 Validate the block (for all blocks in sequential order).) Usage Notes: Use a Pre–Commit trigger to perform an action. then: 6 Issue an SQL-COMMIT statement. . 3 Fire the Pre-Commit trigger. set up special locking Pre-Commit Fires once during commit processing. 2 Process save point. Pre-Commit: Fires once if form changes are made or uncommitted changes are posted 2. .

Pre-Insert Fires during the Post and Commit Transactions process. Example:2 This example assigns a primary key field based on a sequence number.NEXTVAL FROM dual.dummy.. so that the user does not enter an ID manually. /* ** Make sure we populated a new order id ok. Final checks before row deletion 3. END. Note: The Insert Allowed and Keyboard Navigable properties on :S_ORD.. which will be written to the ID column when the row is subsequently inserted. ELSE CLOSE C1. before a row is inserted. CLOSE next_ord. BEGIN OPEN C1.. Begin SELECT S_ORD_ID. flagging creation of a new order. */ .Shik Mahamood Ali 64 • Use a Pre-Delete trigger to prevent the deletion of a record if that record is the master record for detail records that still exist. END IF. FETCH C1 INTO :GLOBAL. and then writes a row into an auditing table. automatically generated columns. then two transactional triggers are usually involved: • Use Pre-Insert to select the next available number from the sequence table (locking the row to prevent other users from selecting the same value) and increment the value by the required amount.id should be No.dual. End.id. IF C1%FOUND THEN MESSAGE(’There are orders for this customer!’). PRE-DELETE TRIGGER -DECLARE CURSOR C1 IS SELECT ’anything’ FROM S_ORD WHERE customer_id = :S_CUSTOMER.nextval INTO :S_ORD. RAISE form_trigger_failure. It fires once for each record that is marked for insert. */ OPEN next_ord. If you use this method.OrderId. ** but explicit cursor is more efficient. Could use SELECT. check constraints Usage Notes: Use a Pre–Insert trigger to perform the following tasks: • change item values • keep track of the date a record is created and store that in the record prior to committing Example:1 This Pre-Insert trigger on the S_ORD block assigns an Order ID from the sequence S_ORD_ID. journaling. BEGIN /* ** Fetch the next sequence number from the ** explicit cursor directly into the item in ** the Order record. recording the new upper value for the sequence. FETCH next_ord INTO :Order.id FROM SYS.INTO. • Use Post-Insert to update the sequence table.. Generate sequence numbers. DECLARE CURSOR next_ord IS SELECT orderid_seq. You can also assign sequence numbers from a table.

SYSDATE ). implement foreign-key update rule. DECLARE old_discount NUMBER..Discount_Pct will be the *new* value we’re getting ready to commit and we want to record for posterity the old and new values.SYSDATE ).5% to 20%’ */ oper_desc := ’Changed Discount from ’|| TO_CHAR(old_discount)||’% to ’|| TO_CHAR(new_discount)||’%’. timestamp ) VALUES ( :Order. check constraints Usage Notes: Use a Pre–Update trigger to audit transactions. before a row is updated.Shik Mahamood Ali 65 IF :Order. END. On-Commit .CustId. Pre-Update Fires during the Post and Commit Transactions process. /* ** Insert a row into the audit table */ INSERT INTO ord_audit( orderid. CLOSE old_value. username. /* ** Insert the audit record with timestamp and user */ INSERT INTO cust_audit( custid. new_discount NUMBER := :Customer. then we need to write out an audit record */ IF old_discount <> new_discount THEN /* Construct a string that shows the operation of Changing the old value to the new value. including timestamp and username making the change. 4. ’New Order’. /* ** If the old and current values are different. username. timestamp ) VALUES ( :Customer. Example: The following example writes a row into an Audit Table showing old discount and new discount for a given customer. operation.CustId.USER. BEGIN /* ** Fetch the old value of discount percentage from the database by CustomerId. oper_desc VARCHAR2(80).INTO but choose an explicit cursor for efficiency.OrderId. It fires once for each record that is marked for update. We need to do this since the value of :Customer. */ OPEN old_value. END IF. FETCH old_value INTO old_discount. 5.Discount_Pct. CURSOR old_value IS SELECT discount_pct FROM customer WHERE CustId = :Customer. RAISE Form_Trigger_Failure. USER. END IF.OrderId IS NULL THEN Message(’Error Generating Next Order Id’). Journaling. operation.g. ** ’Changed Discount from 13. We could use SELECT.oper_desc. auto-generated columns. END. e..

/* ** otherwise. BEGIN UPDATE emp SET termination_date = SYSDATE WHERE empno = :Emp. 7. call to the COMMIT_FORM built–in. no action is performed */ END. Specifically. BEGIN IF Get_Application_Property(DATA_SOURCE) = ’ORACLE’ THEN Commit_Form. • To perform the default processing from this trigger. It fires once for each row that is marked for insertion into the database. Description When called from an On-Insert trigger.Empno. replacing the actual database delete of a given row. that is. when Form Builder would normally insert a record in the database. END IF. On-Delete Fires during the Post and Commit Transactions process. this operation occurs after all records that have been marked as updates. 6. it fires after the Pre–Delete trigger fires and before the Post–Delete trigger fires.Shik Mahamood Ali 66 Fires whenever Oracle Forms would normally issue a database commit statement to finalize a transaction. The trigger fires once for each row that is marked for deletion from the database. rather than actually deleting the employee from the database. to delete a record from your form or from the database. Specifically. Syntax PROCEDURE INSERT_RECORD. Example: This example disables the commit operation when running against a datasource that does not support transaction control. include a call to the DELETE_RECORD built–in. To perform the default Form Builder processing from this trigger. On-Insert Fires during the Post and Commit Transactions process when a record is inserted. Example: This example updates the employee table to set the Termination_Date. To perform the default Oracle Forms processing from this trigger. Usage Notes: • Use an On–Commit trigger to change the conditions of normal Oracle Forms commit processing to fit the particular requirements of a commit to a non–ORACLE database. END. By default. This built-in is included primarily for applications that will run against a non-ORACLE datasource. include a call to the INSERT_RECORD built-in. inserts. If the application is running against ORACLE. it fires after the Pre-Insert trigger fires and before the Post-Insert trigger fires. inserts the current record into the database during Post and Commit Transactions processing. the commit operation behaves normally. . Usage Notes • • Use an On-Insert trigger to replace the default Form Builder processing for handling inserted records during transaction posting. and deletes have been posted to the database. Usage Notes: • • Use an On–Delete trigger to replace the default Oracle Forms processing for handling deleted records during transaction posting.

8. it fires after the Pre–Update trigger fires and before the Post–Update trigger fires. When called from an On-Update trigger. • Locking statements are not issued.. and deletes have been posted to the . perhaps based on a parameter.) UPDATE base_table SET base_column = :base_item. do the right thing. ** Trigger: On-Insert */ BEGIN /* ** Check the global flag we setup at form startup */ IF :Global...) VALUES ( :base_item. End. */ ELSE Insert_Record. Usage Notes: • • Use an On–Update trigger to replace the default Oracle Forms processing for handling updated records during transaction posting. To perform the default Oracle Forms processing from this trigger. when Oracle Forms would normally update a record in the database.WHERE ROWID = :ROWID DELETE FROM base_table WHERE ROWID = :ROWID DML Statements Issued During Commit Processing Rules: • DML statements may fire database triggers. • The Update Changed Columns Only and Enforce Column Security properties affect UPDATE statements.. base_column = :base_item. /* ** Otherwise. base_column. :base_item. .. END IF. 9.Shik Mahamood Ali 67 /* ** Built-in: INSERT_RECORD ** Example : Perform Form Builder standard insert processing ** based on a global flag setup at startup by the ** form. This builtin is included primarily for applications that run against a non-ORACLE data source. initiates the default Form Builder processing for updating a record in the database during the Post and Commit Transaction process. include a call to the UPDATE_RECORD built–in.Using_Transactional_Triggers = 'TRUE' THEN User_Exit('my_insrec block=EMP'). Post – Database Commit Description Fires once during the Post and Commit Transactions process. On-Update Fires during the Post and Commit Transactions process.. END. . DML Statements Issued During Commit Processing INSERT INTO base_table ( base_column.. It fires once for each row that is marked for update in the form. • Form Builder uses and retrieves ROWID. Note that the Post-Forms-Commit trigger fires after inserts. Specifically. Begin UPDATE RECORD. updates. after the database commit occurs.

the Post-Forms-Commit trigger fires after these changes have been written to the database but before Form Builder issues the database Commit to finalize the transaction.'Global. */ BEGIN :Global. /* FUNCTION recs_posted_and_not_committed RETURN BOOLEAN IS BEGIN Default_Value('TRUE'. END. but before the transaction has been finalized by issuing the Commit. anytime a database commit is about to occur. END. Form Builder fires the Post-Forms-Commit trigger immediately. Usage Notes • • Use a Post-Forms-Commit trigger to perform an action. Post – Delete Fires during the Post and Commit Transactions process.Did_DB_Commit'). updates.Did_DB_Commit = 'FALSE').Did_DB_Commit := 'FALSE'.Shik Mahamood Ali 68 database. 11. without posting changes to the database.Form_Status = 'QUERY' AND :Global.Form_Status = 'QUERY'AND :Global. */ BEGIN :Global.Commit Fires once during the Post and Commit Transactions process. END. or deletes. If the operator or the application initiates a Commit when there are no records in the form have been marked as inserts. Post-Database-Commit Determines if commit was successful.'Global. Post-Forms-Commit Checks complex multirow constraints Example This example can be used in concert with the Post-Database-Commit trigger to detect if records have been posted but not yet committed.Did_DB_Commit = FALSE'). form or block Usage Notes: . determines if there are posted. after a row is deleted. If there are records in the form that have been marked as inserts.Did_DB_Commit'). RETURN (:System. updates. The Post-DatabaseCommit Trigger fires after Form Builder issues the Commit to finalize the transaction. Example /* ** FUNCTION recs_posted_and_not_committed ** RETURN BOOLEAN IS BEGIN Default_Value('TRUE'. uncommitted changes 10. It fires once for each row that is deleted from the database during the commit process. Post – Form .Did_DB_Commit := 'FALSE'. END. or deletes. RETURN (:System. Usage Notes Use a Post-Database-Commit trigger to perform an action anytime a database commit has occurred. such as updating an audit trail.

IF SQL%NOTFOUND THEN MESSAGE(’Record not found in database’). Example . RAISE form_trigger_failure. End.insert_tot)+1). SYSDATE.along with a time stamp and the user who performed the update. USER ). Example .1 Begin INSERT INTO delete_audit (id.id. Post – Insert Fires during the Post and Commit Transactions process. Else Messafe(SQL%rowcount|| “ rows Deleted”). Post-Insert trigger: Begin INSERT INTO LOG_TAB (LOG_VAL. Write changes to nonbase tables.||SQLERRM). End. END IF.Shik Mahamood Ali 69 Use a Post–Delete trigger to audit transactions. 12. Usage Notes: Use a Post–Update trigger to audit transactions. Example 1 Keeping an Audit Trail :GLOBAL.id. • • • Use a Post-Insert trigger to audit transactions.username). Gather statistics on applied changes. Example 2 To handle exceptions. EXCEPTION WHEN OTHERS THEN MESSAGE(’Error! ’. after a row is updated. It fires once for each record that is inserted into the database during the commit process.insert_tot := TO_CHAR(TO_NUMBER(:GLOBAL. timestamp. who_did_it)VALUES ( :S_ORD. Post – Update Fires during the Post and Commit Transactions process. End. It fires once for each row that is updated in the database during the commit process. This Post-Update trigger writes the current record ID to the UPDATE_AUDIT table. just after a record is inserted.:GLOBAL. LOG_USER) VALUES(:S_DEPT. include EXCEPTION section in trigger. Example .1 Begin . 13.id.2 Begin Delete from S_ORD SET WHERE id = :S_ORD.

*/ OPEN next_ord. To perform the default Form Builder processing from this trigger. End. On-Select replaces open cursor. Could use SELECT. Specifically. CLOSE next_ord. username. This example assigns a primary key field based on a sequence number. 15.INTO. Query Processing Triggers Uses 14.Select Fires when Form Builder would normally execute the open cursor. and execute phases. include a call to the SELECT_RECORDS built-in.id. Usage Notes • Use an On-Select trigger to open and execute the database cursor. and execute phases of a query. END. End.OrderId. who_did_it)VALUES ( :S_ORD. The On-Select trigger can be used in conjunction with the On-Fetch trigger to replace the processing that normally occurs in the EXECUTE_QUERY built-in subprogram. RAISE form_trigger_failure. use this trigger when you are retrieving data from a non-ORACLE data source. RAISE Form_Trigger_Failure. parse. ** but explicit cursor is more efficient. On . END IF. 70 INSERT INTO update_audit (id. after Form Builder constructs the SELECT statement to be issued.OrderId IS NULL THEN Message(’Error Generating Next Order Id’).LAST_QUERY Fires after Form Builder has constructed the block SELECT statement based on the query conditions..USER.Shik Mahamood Ali USER ). • Example . but before it issues this statement Use a Pre-Select trigger to prepare a query prior to execution against a non-ORACLE data source. /** Insert a row into the audit table INSERT INTO ord_audit( orderid.. END IF.1 . timestamp ) VALUES ( :Order. DECLARE CURSOR next_ord IS SELECT orderid_seq. IF SQL%NOTFOUND THEN MESSAGE(’Record not found in database’). operation. Pre – Select Fires during Execute Query and Count Query processing.id.2 Begin UPDATE S_ORD SET date_shipped = SYSDATE WHERE id = :S_ORD. Note that the SELECT statement can be examined in a Pre-Select trigger by reading the value of the system variable SYSTEM. parse. but before the statement is actually issued. BEGIN /** Fetch the next sequence number from the Explicit cursor directly into the item in the Order record. and then writes a row into an auditing table. SYSDATE. IF :Order.’New Order’. to identify the records in the database that match the current query criteria. FETCH next_ord INTO :Order. timestamp.OrderId. flagging creation of a neworder. Example .NEXTVAL FROM dual.SYSDATE ).

On–Fetch: DECLARE j NUMBER := Get_Block_Property(blk_name.ename := emprow. – It raises FORM_TRIGGER_FAILURE.ENAME.. :Emp. */ EXIT WHEN NOT MyPackage. End. Create_Queried_Record. but before it fetches the records The Post-Select trigger fires after the default selection phase of query processing.Shik Mahamood Ali 71 In the following example.j LOOP /* ** Try to get the next row. :Emp. RECORDS_TO_FETCH). On – Fetch Fires when Form Builder performs a fetch for a set of rows (You can use the CREATE_QUERIED_RECORD built-in to create queried records if you want to replace default fetch processing. END IF. :Emp. Post-Select Trigger Description Fires after Form Builder has constructed and issued the block SELECT statement.Get_Next_Row(emprow). END LOOP. . emprow emp%ROWTYPE. to perform a query against a database. Usage Note: Use the Post-Select trigger to perform an action based on the outcome of the Select phase of query processing such as an action based on the number of records that match the query criteria. 16.EMPNO. – The query is closed by the user or by ABORT_QUERY. IF Form_Failure OR Form_Fatal THEN ABORT_QUERY. SELECT_RECORDS. The trigger will fire once for each record that is to be fetched. IF form_fatal OR form_failure THEN raise form_trigger_failure.' and a built-in subprogram. 15. the On-Select trigger is used to call a user exit. */ Select_Records. Begin IF Get_Application_Property(DATASOURCE) = 'DB2' THEN User_Exit ( 'Query' ). 'Query. It fires before any records are actually retrieved through fetch processing. ELSE /* ** Perform the default Form Builder task of opening the query. END IF. BEGIN FOR ctr IN 1.rowid := emprow.empno := emprow.ROWID. or after the successful execution of the On-Select trigger.) • On-Fetch continues to fire until: – It fires without executing CREATE_QUERIED_RECORD.

Shik Mahamood Ali END IF. you can set the value of the Query_Hits block property to indicate the number of records in the non-ORACLE data source that match the query criteria. include a call to the built-in. • Form Builder will display the query hits message (FRM-40355) even if the On-Count trigger fails to set the value of the Query_Hits block property.1 This example calls a user-named subprogram to count the number of records to be retrieved by the current query criteria. Decide whether to use this Built-in or a user ** exit based on a global flag setup at startup by the form. On – Count Fires when Form Builder would usually perform default Count Query processing to determine the number of rows that match the query conditions Fires when Form Builder would normally perform default Count Query processing to determine the number of rows in the database that match the current query criteria. END.Name_In('DEPT. Usage Notes • Use an On-Count trigger to replace default Count Query processing in an application running against a non-ORACLE data source. Example 3 /* ** Built-in: COUNT_QUERY ** Example: Perform Form Builder count query hits processing.j). DECLARE j NUMBER. Example 2 /* ** Built-in: COUNT_QUERY ** Example: Display the number of records that will be retrieved ** by the current query. Example . and sets the Query_Hits property appropriately. the message reports 0 records identified.DNAME')). In such a case. BEGIN j := Recs_Returned('DEPT'. When the On-Count trigger completes execution. Count_Query. perhaps based on a parameter. * Trigger: On-Count */ . Set_Block_Property('DEPT'. • If you are replacing default processing. END. Form Builder issues the standard query hits message: FRM-40355: Query will retrieve <n> records. 72 16. • To perform the default Form Builder processing from this trigger. */ BEGIN END.QUERY_HITS.

/* ** Otherwise. Form Builder queries the database to get the next value from the SEQUENCE whenever the Create Record event occurs. Count_Query. */ Set_Block_Property(:System.On-Sequence-Number Trigger Description Fires when Form Builder would normally perform the default processing for generating sequence numbers for default item values. . ** Trigger: On–Sequence–Number */ BEGIN /* ** Check the global flag we setup at form startup */ IF :Global. */ ELSE END.HITS item. perhaps based on a parameter.Using_Transactional_Triggers = 'TRUE' THEN /* ** User exit returns query hits count back into the ** CONTROL.Trigger_Block. Example: /* ** Built–in: GENERATE_SEQUENCE_NUMBER ** Example: Perform Oracle Forms standard sequence number processing based on a global flag setup at ** startup by the form.:control. do the right thing. /* ** Deposit the number of query hits in the appropriate ** block property so Form Builder can display its normal ** status message. Suppress or override this functionality with an On-Sequence-Number trigger.Using_Transactional_Triggers = ’TRUE’ THEN User_Exit(’my_seqnum seq=EMPNO_SEQ’).QUERY_HITS. Usage Notes • When a SEQUENCE is used as a default item value. */ User_Exit('my_count'). Replaces the default series of events that occurs when Form Builder interacts with the database to get the next value from a SEQUENCE object defined in the database. END IF. call the GENERATE_SEQUENCE_NUMBER built-in. do the right thing. 17.Shik Mahamood Ali BEGIN 73 /* ** Check the global flag we set during form startup */ IF :Global. */ ELSE Generate_Sequence_Number.hits). • To perform the default Form Builder processing from this trigger. /* ** Otherwise.

and free memory. . It fires once for each record that has been inserted or updated. Form Builder displays message FRM-40600: Record has already been inserted. tmp VARCHAR2(1). On-Close Trigger Description Fires when an operator or the application causes a query to close. checks the uniqueness of a record by constructing and executing the appropriate SQL statement to select for rows that match the current record's primary key values.deptno. close cursors. Usage Notes • • Use an On-Close trigger after using the On-Select or On-Fetch triggers. By default. FETCH chk_unique INTO tmp. On-Check-Unique Trigger 74 Description During a commit operation. END. The On-Close trigger augments the normal Form Builder "close cursor" phase of a query. specifically. END IF. Replaces the default processing for checking record uniqueness. The On-Close trigger fires automatically when the ABORT_QUERY built-in is called from an On-Select trigger. END. DECLARE CURSOR chk_unique IS SELECT 'x' FROM dept WHERE deptno = :dept. to close files. RAISE Form_Trigger_Failure. When a block has the PRIMKEYB property set to Yes. Form Builder. Usage Notes To perform the default processing from this trigger. Form Builder always checks for unique primary key values. If a duplicate row is found. On-Check-Unique Trigger examples The following example verifies that the current record in question does not already exist in the DEPT table. the On-Check-Unique trigger fires when Form Builder normally checks that primary key values are unique before inserting or updating a record in a base table. call the CHECK_RECORD_UNIQUENESS built-in. For a record that has been marked for insert. In the case of an update. by default. BEGIN OPEN chk_unique. Form Builder closes a query when all of the records identified by the query criteria have been fetched. IF tmp IS NOT NULL THEN Message('This department already exists. 19. or when the operator or the application aborts the query. CLOSE chk_unique.Shik Mahamood Ali END IF. 18. Form Builder checks for unique primary key values only if one or more items that have the Primary Key item property have been modified.').

itm_id := Find_Item('Emp. Example The following example sets salary and commission text items in the current block to disabled and non-updateable. Set_Item_Property(itm_id. BEGIN IF NOT my_data source_open('DX110_DEPT') THEN my_datasource_close('DX110_DEPT').on_or_off).on_or_off). Set_Item_Property(itm_id. processing each block in sequence.ENABLED. unless the SUPERUSER role is enabled. On-Rollback Trigger Description Fires when Form Builder would normally issue a ROLLBACK statement.UPDATEABLE. call the ENFORCE_COLUMN_SECURITY built-in. Form Builder makes the corresponding base table items in the form non-updateable by setting the Update Allowed item property Off dynamically. 21.Comm'). Form Builder performs this operation at form startup. END. END. ELSE on_or_off := PROPERTY_ON. Only users with the user-defined SUPERUSER role can change these number fields.on_or_off).UPDATEABLE. Usage Notes To perform the default processing from this trigger.ENABLED. END IF. On-Column-Security Trigger Description Fires when Form Builder would normally enforce column-level security for each block that has the Enforce Column Security block property set On. Set_Item_Property(itm_id.Sal'). Set_Item_Property(itm_id. itm_id := Find_Item('Emp. For columns to which the operator does not have update privileges. BEGIN IF NOT role_is_set('SUPERUSER') THEN on_or_off := PROPERTY_OFF. to roll back a . on_or_off NUMBER. Form Builder enforces column security by querying the database to determine the base table columns to which the current form operator has update privileges. DECLARE itm_id Item. By default.Shik Mahamood Ali 75 Example The following example releases memory being used by a user-defined data access method via the transactional triggers. END IF. 20.on_or_off).

if you want to create an application that does not require a data source. include a call to the LOGON built–in. Usage Notes Use an On-Rollback trigger to replace standard Form Builder rollback processing. BEGIN /* Get the name of the savepoint to which Form Builder needs to ** rollback. • • • Pre–Logon and Post–Logon triggers fire as part of the logon procedure. ** perhaps based on a parameter. ISSUE_ROLLBACK examples /* ** Built-in: ISSUE_ROLLBACK ** Example: Perform Form Builder standard Rollback processing. To perform default Form Builder processing from this trigger. ** Decide whether to use this built-in based on a ** global flag setup at startup by the form.Shik Mahamood Ali 76 transaction to the last savepoint that was issued. include a call to the ISSUE_ROLLBACK built-in. You can supply a NULL command to this trigger to bypass the connection to a data source. ELSE Issue_Rollback(sp_name). (NULL = Full Rollback)*/ sp_name := Get_Application_Property(SAVEPOINT_NAME). Usage Notes Use a Pre-Logon trigger to prepare the form for the logon procedure. J. ** Trigger: On-Rollback */ DECLARE sp_name VARCHAR2(80).Using_Transactional_Triggers = 'TRUE' THEN User_Exit('my_rollbk name='||sp_name). 2. On-Logon Trigger Fires once per logon when Oracle Forms normally initiates the logon sequence.LOGON TRANSACTION TRIGGERS 1. DECLARE connected BOOLEAN:=FALSE. To perform the default Oracle Forms processing from this trigger. Usage Notes: Use an On–Logon trigger to initiate a logon procedure to a non–ORACLE data source. particularly to a nonORACLE data source. END IF . . END. Pre-Logon Trigger Fires just before Form Builder initiate a logon procedure to the data source. /* ** Check the global flag we setup at form startup */ IF :Global.

3.’DEFAULT’). RAISE FORM_TRIGGER_FAILURE. IF NOT CONNECTED THEN MESSAGE(‘Too many tries’). un:=GET_APPLICATION_PROPERTY( USERNAME ). Usage Notes • • Use a Pre-Logout trigger to prepare the form for logging out from the data source. FALSE ). For example. Example This example calls a user exit to log the current username and time to an encrypted audit trail file on the file system. particularly a non-ORACLE data source. the results are undefined. BEGIN 77 SET_APPLICATION_PROPERTY(CURSOR_STYLE. If you call certain built-ins from within one of the Logout triggers. cs:= GET_APPLICATION_PROPERTY( CONNECTION_STRING ). 4. END LOOP. pw || ‘@’ || CS . LOGON( un. un NUMBER.'YYYYMMDDHH24MISS')). pw VARCHAR2(30). END. the COPY built-in cannot be called from a Pre-Logout trigger . END IF. pw:=GET_APPLICATION_PROPERTY( PASSWORD ). END IF. cs VARCHAR2(30). Pre-Logout Trigger Fires once before Form Builder initiate a logout procedure. The successful execution of the On-Logon trigger. BEGIN END. IF FORM_SUCESS THEN Connected:=TRUE. which for security reasons is outside the database. POST-LOGON TRIGGER Description Fires after either of the following events: • • The successful completion of Form Builder default logon processing. User_Exit('LogCrypt '|| USER||' ' ||TO_CHAR(SYSDATE. WHILE CONNECTED = FALSE AND tries > 0 LOOP LOGON_SCREEN.Shik Mahamood Ali tries NUMBER:=3. Tries:=tries-1.

a COPY operation is not possible. the results are undefined. 5. If you call certain built-ins from within one of the Logout triggers.’YYYYMMDDHH24MISS’)). When-Mouse-Click Trigger . Because the form is no longer accessible. On-Logout Trigger Fires when Form Builder normally initiates a logout procedure from Form Builder and from the RDBMS. BEGIN User_Exit(’LogCrypt ’||USER||’ ’ || TO_CHAR(SYSDATE. Because the form is no longer accessible at this point. J. • If you call certain built-ins from within one of the Logout triggers.MOUSE TRIGGERS 1. Post-Logout Trigger Description Fires after either of the following events: • • Form Builder successfully logs out of ORACLE. the results are undefined. Usage Notes • • • Use an On-Logout trigger to replace the default logout processing either from the RDBMS or from a non-ORACLE data source.Shik Mahamood Ali 78 because Pre-Logout fires after the Leave the Form event. include a call to the LOGOUT built-in. This example calls a user exit to log the current username and time to an encrypted audit trail file on the file system. For example. Because the form is no longer accessible. For example. Usage Notes • Use a Post-Logout trigger to audit or to perform tasks on an Form Builder application that does not require or affect the RDBMS or other data source. which for security reasons is outside the database. you cannot call COPY from a Pre-Logout trigger because Pre-Logout fires after the Leave the Form event. The successful execution of the On-Logout trigger. To perform the default Form Builder processing from this trigger. you cannot call the COPY built-in from a Pre-Logout trigger because Pre-Logout fires after the Leave the Form event. END. the COPY operation is not possible. a COPY operation is not possible. 6.

when the mouse is clicked within the item Three events must occur before a When-Mouse-Click trigger will fire: • • • Mouse down Mouse up Mouse click Any trigger that is associated with these events will fire before the When-Mouse-Click trigger fires. Usage Notes Use the When-Mouse-Click trigger to perform an action every time the operator clicks the mouse within an item and/or canvas. when the mouse is clicked within any canvas or item in the form if attached to a block. when the mouse is double-clicked within the item Six events must occur before a When-Mouse-DoubleClick trigger will fire: • • • • • • Mouse Mouse Mouse Mouse Mouse Mouse down up click down up double-click Any trigger that is associated with these events will fire before the When-Mouse-DoubleClick trigger fires. when the mouse is clicked within any item in the block if attached to an item. When-Mouse-DoubleClick Trigger examples Example . When-Mouse-DoubleClick Trigger Description Fires after the operator double-clicks the mouse if one of the following events occurs: • • • if attached to the form. 2. when the mouse is double-clicked within any item in the block if attached to an item. Usage Notes Use a When-Mouse-DoubleClick trigger to perform an action every time the operator DoubleClick the mouse within an item and/or canvas. when the mouse is double-clicked within any canvas or item in the form if attached to a block.Shik Mahamood Ali Description 79 Fires after the operator click the mouse if one of the following events occurs: • • • if attached to the form.

assume that your When-Mouse-Enter trigger causes Alert_One to appear whenever the mouse enters Canvas_One. so the user is never able to click on those items. the trigger fires and returns focus to the previous target. Further. assume that the mouse has entered Canvas_One causing the When-Mouse-Enter trigger to fire which in turn causes Alert_One to appear. Do not use the When-Mouse-Enter trigger on a canvas that is larger than the window. when the mouse enters any item in the block if attached to an item. Iconic buttons and items on the canvas below the initial window cannot be selected. Canvas_One and Canvas_Two do not overlap each other. assume that Alert_One displays within Canvas_Two's border. Finally. but appear side by side on the screen. 3. as soon as the mouse enters that area. when the mouse is pressed within the item Usage Notes • Use a When-Mouse-Down trigger to perform an action every time the operator presses down the mouse button within an item and/or canvas. when the mouse is pressed down within any item in the block if attached to an item. Be careful when calling a modal window from a When-Mouse-Enter trigger. when the mouse enters any canvas or item in the form if attached to a block.Shik Mahamood Ali 80 Assume that an application requires Behavior A when the operator clicks the mouse and Behavior B when the operator double-clicks the mouse. Changing a tooltip's property in a When-Mouse-Enter trigger cancels the tooltip before it is ever shown. 4. an online help window must appear. Assume also that your application contains two canvases. if the operator clicks the mouse. Doing so may cause the modal window to appear unnecessarily. When-Mouse-Down Trigger Description Fires after the operator presses down the mouse button if one of the following events occurs: • • • if attached to the form. However. when the mouse is pressed down within any canvas or item in the form if attached to a block. . For example. Note: The mouse down event is always followed by a mouse up event. The user is able to scroll the canvas to see the items. For example. Canvas_One and Canvas_Two. a product information window must appear. If the operator double-clicks the mouse. When-Mouse-Enter Trigger Description Fires when the mouse enters an item or canvas if one of the following events occurs: • • • if attached to the form. when the mouse enters the item Usage Notes Use a When-Mouse-Enter trigger to perform an action every time the mouse enters an item or canvas.

show_help_button := ’?’.save_item_name := :SYSTEM. .CURSOR_ITEM.Shik Mahamood Ali 81 When the operator dismisses the message box.show_help_button begin End. any When-Mouse-Leave triggers associated with this event will fire. End. HIDE_VIEW(’cv_help’). In addition. GO_ITEM(:GLOBAL. End. when the mouse moves within any item in the block if attached to an item. 6. when the operator moves the mouse out of Canvas_Two. when the mouse leaves the item Usage Notes Use a When-Mouse-Leave trigger to perform an action every time the mouse leaves an item and/or canvas. The When-Mouse-Move trigger may have performance implications because of the number of times this trigger can potentially fire. begin :GLOBAL. Alert_One will appear again unnecessarily if the operator subsequently enters Canvas_One with the mouse. when the mouse moves within the item Usage Notes • Use the When-Mouse-Move trigger to perform an action every time the operator moves the mouse. when the mouse moves within any canvas or item in the form if attached to a block.save_item_name).MOUSE_CANVAS = ’CV_ORDER’ THEN :control. END IF. WHEN-MOUSE-ENTER at Form Level begin IF :SYSTEM. 5. When-Mouse-Leave Trigger Description Fires after the mouse leave an item or canvas if one of the following events occurs: • • • if attached to the form. when the mouse leaves any canvas or item in the form if attached to a block. GO_ITEM(’s_ord. SHOW_VIEW(’cv_help’). This may not be the desired behavior. WHEN-MOUSE-LEAVE trigger on control. when the mouse leaves any item in the block if attached to an item.id’). When-Mouse-Move Trigger Description Fires each time the mouse moves if one of the following events occurs: • • • if attached to the form.

Create a user-named trigger to execute user-named subprograms defined in a form document from menu PL/SQL commands and user-named subprograms. the trigger defined at the lowest level has precedence. As with all triggers.OTHER TRIGGERS 1. If the operator presses down the mouse on Item_One. When more than one user-named trigger has the same name. The mouse up event is always associated with the item that received the mouse down event. which in turn calls the user-named subprogram defined in the current form. (User-named subprograms defined in a form cannot be called directly from menu PL/SQL. the scope of a user-named trigger is the definition level and below. Note: You can write user–named PL/SQL subprograms to perform almost any task for which you might use a user–named trigger. If no such key . call the EXECUTE_TRIGGER built-in to execute a usernamed trigger. DO_KEY built-in Executes the key trigger that corresponds to the specified built-in subprogram. as shown here: Execute_Trigger(’my_user_named_trigger’). when the mouse up event is received within any canvas or item in form attached to a block. which is defined in a different document. and then call explicitly from other triggers or user–named subprograms. rather than for Item_Two. User-Named Trigger A user–named trigger is a trigger that you define yourself in a form. Usage Notes User-named PL/SQL subprograms can be written to perform almost any task for which one might use a user-named trigger.Shik Mahamood Ali 7. you must call the EXECUTE_TRIGGER built–in procedure. It is most practical to define user-named triggers at the form level. Each user–named trigger defined at the same definition level must have a unique name.) In the menu PL/SQL. assume that there is a When-Mouse-Up trigger attached to Item_One. but then releases the mouse on Item_Two. For example. when the mouse up event is received within any item in a block attached to an item. When-Mouse-Up Trigger 82 Description Fires each time the operator presses down and releases the mouse button if one of the following events occurs: • • • if a if if attached to the form. To execute a user–named trigger. K. the mouse up trigger will fire for Item_One. when the mouse up event is received within an item Two events must occur before a When-Mouse-Up trigger will fire: • • Mouse down Mouse up Usage Notes Use the When-Mouse-Up trigger to perform an action every time the operator presses and releases the mouse.

Form Builder does not issue savepoints and. 2. By default. /* Otherwise. Syntax PROCEDURE DO_KEY (built-in_subprogram_name VARCHAR2).Shik Mahamood Ali 83 trigger exists. DO_KEY restrictions DO_KEY accepts built-in names only. the On-Savepoint trigger never fires. In an On-Rollback trigger . and at the start of each Post and Commit Transaction process.perhaps based on a parameter. not key names: DO_KEY(ENTER_QUERY). To accept a specific key name. if no On-Savepoint trigger were present. In an On-Savepoint trigger. use the EXECUTE_TRIGGER built-in: EXECUTE_TRIGGER('KEY_F11'). do the right thing. ** Decide whether to use this built-in based on a global flag setup at startup by the form. /* ** Built-in: ISSUE_SAVEPOINT ** Example: Perform Form Builder standard savepoint processing. Form Builder issues savepoints at form startup. Suppress default savepoint processing by setting the Savepoint Mode form document property to Off. Do_Key('Execute_Query'). /* Check the global flag we setup at form startup */ IF :Global.consequently. ** Trigger: On-Savepoint */ DECLARE sp_name VARCHAR2(80). */ BEGIN END. When Savepoint Mode is Off. BEGIN /* Get the name of the savepoint Form Builder needs to issue */ sp_name := Get_Application_Property(SAVEPOINT_NAME). */ ELSE . include a call to the ISSUE_SAVEPOINT built-in. DO_KEY examples /* ** Built-in: DO_KEY ** Example: Simulate pressing the [Execute Query] key. On-Savepoint Trigger Fires when Form Builder would normally issue a Savepoint statement. This behavior is analogous to pressing the corresponding function key. the Savepoint_Name application property returns the name of the next savepoint that Form Builder would issue by default. Usage Notes To perform default Form Builder processing from this trigger.Using_Transactional_Triggers = 'TRUE' THEN User_Exit('my_savept name='||sp_name). Savepoint_Name returns the name of the savepoint to which Form Builder would roll back. then the specified subprogram executes.

Decide whether to use default processing or a user exit by consulting a global flag setup at startup by the form. if you are designing an application for use on a single–user system. Form Builder marks the corresponding items and records as changed. use On–Lock if you are accessing a non–ORACLE data source directly. In other words. On-Lock Trigger Fires whenever Oracle Forms would normally attempt to lock a row. you can use the On–Lock trigger to speed processing by bypassing all lock processing. If you want to circumvent this situation and effectively get rid of the Post-Change trigger. The Post-Query trigger does not have the restrictions of the Post-Change trigger. Form Builder fetches a non-NULL value into an item. the trigger fires once. not by way of Open Gateway. • To perform the default Oracle Forms processing from this trigger. and the item is not NULL. END. In this case. 3. An operator returns a value into an item by making a selection from a list of values.perhaps based on a parameter.Shik Mahamood Ali Issue_Savepoint(sp_name). The trigger does not fire during subsequent modifications to items in the same record. 3. /* ** Built-in: LOCK_RECORD ** Example: Perform Form Builder standard record locking on the queried record which has just been deleted or updated. Its use is not recommended in new applications. Post-Change Trigger 84 Fires when any of the following conditions exist: • • • The Validate the Item process determines that an item is marked as Changed and is not NULL. See "Usage Notes" below. You can use Post-Query to make changes to the fetched database values. END IF. The trigger fires between the key press and the display of the modified data. For example. Usage Notes: • Use an On–Lock trigger to replace the default Oracle Forms processing for locking rows. you must include a Post-Query trigger in addition to your When-Validate-Item trigger. the When-ValidateItem trigger does not fire. the trigger fires only the first time the operator tries to modify an item in the record. include a call to the LOCK_RECORD built–in. • Use this trigger to lock underlying tables for non–updateable views. ** Trigger: On-Lock */ BEGIN . Also. Given such changes. such as when an operator presses a key to modify data in an item. for every row that is to be locked. • When the On–Lock trigger fires as a result of an operator trying to modify data. Usage Notes • • The Post-Change trigger is included only for compatibility with previous versions of Form Builder.

Query-Procedure Trigger Automatically created by Form Builder when the query data source is a stored procedure. 6. do the right thing.) Actions defined for this trigger are performed before the pop-up menu is displayed.CUSTOM_ITEM_EVENT stores the case–sensitive name of the event that occurred. any of the items may be used. Usage Notes Use this trigger to enable or disable menu items on a pop-up menu before it is displayed. END. Usage Notes: Use a When–Custom–Item–Event trigger to respond to a selection or change of value for a VBX control. Think of this as an On-Update trigger that is called by the system instead of doing default update operations. This trigger is called when a update operation is necessary. the query stored procedure has to use those values to filter the data. 5. Think of this as an On-Query trigger that is called by the system instead of doing default query operations. DECLARE TabEvent varchar2(80). Lock_Record. .Shik Mahamood Ali 85 /* ** Check the global flag we set up at form startup */ IF :Global. Update-Procedure Trigger Automatically created by Form Builder when the update data source is a stored procedure. Example: This is an example of a procedure that can be called when Oracle Forms fires the When–Custom–Item–Event Trigger. This means that the enter query mode does not happen automatically unless you specify it. this occurs when a user presses the right mouse button. 7. but the Query Data Source Columns property must be set so that those items can be passed to the query stored procedure. 8.CUSTOM_ITEM_EVENT_PARAMETERS stores a parameter name that contains the supplementary arguments for an event that is fired by a VBX control. The system variable SYSTEM.Non_Oracle_Datasource = 'TRUE' THEN User_Exit('my_lockrec block=EMP'). Then. /* ** Otherwise. */ ELSE END IF. and the system variable SYSTEM. Pre-Popup-Menu Trigger This trigger is called when a user causes a pop-up menu to be displayed. This trigger is called when a query operation is necessary. Usage Notes When constructing a query. TabNumber Number. When-Custom-Item-Event Trigger Fires whenever a VBX control sends an event to Oracle Forms. (In a Microsoft Windows environment.

When-Form-Navigate Trigger Fires whenever any peer form navigation takes place.MAXIMIZE). . but the trigger will not fire if an end user presses [Next Item] (Tab) to navigate from one field to another field in the same block. BEGIN if (GET_WINDOW_PROPERTY(win_id. DECLARE win_id WINDOW := FIND_WINDOW(’WINDOW12’). it does not respond to implicit navigation.Get_Property(’TABCONTROL’.MINIMIZE). /* ** After detecting a Click event. and use the user– defined Goto_Tab_Page procedure to navigate to the selected page. 10. • When-Tab-Page-Changed does not fire when the tab page is changed programmatically. label). When-Tab-Page-Changed Fires whenever there is explicit item or mouse navigation from one tab page to another in a tab canvas.Shik Mahamood Ali 86 BEGIN TabEvent := :system. tp_id TAB_PAGE. tp_id := FIND_TAB_PAGE(tp_nm).’CurrTab’). tp_lb := GET_TAB_PAGE_PROPERTY(tp_id.WINDOW_STATE. form Use a When–Form–Navigate trigger to perform actions when any cross form navigation takes place without relying on window activate and window deactivate events. Usage Notes • Use a When-Tab-Page-Changed trigger to perform actions when any tab page is changed during item or mouse navigation. Goto_Tab_Page(TabNumber). */ IF (UPPER(TabEvent) = ’CLICK’) THEN TabNumber := VBX. END IF. END. topmost_tab_page).custom_item_event.WINDOW_STATE) = ’MAXIMIZE’ THEN SET_WINDOW_PROPERTY(win_id. Example /* Use a When-Tab-Page-Changed trigger to dynamically change a tab page's label from lowerto upper-case (to indicate to end users if they already have ** navigated to the tab page): */ DECLARE tp_nm VARCHAR2(30). identify the ** tab selected. else SET_WINDOW_PROPERTY(win_id. 9. the trigger will fire when the mouse or keyboard is used to navigate between tab pages. This is an example of a procedure that can be called when Oracle Forms fires the When–Form– Navigate Trigger. tp_lb VARCHAR2(30). but on different tab pages. end if. • When-Tab-Page-Changed fires only when tab page navigation is explicit. For example.WINDOW_STATE. END. BEGIN tp_nm := GET_CANVAS_PROPERTY('emp_cvs'.

Only end-user action will generate an event. allowing the operator to view and select undisplayed values. END IF. When the text list contains values that cannot be displayed (due to the displayable area of the item). No programmatic action will cause the When-Tree-Node-Expanded trigger to fire. SYSTEM. .TRIGGER_NODE returns a value of type NODE. Unlike the poplist or the text list style list items.TRIGGER_NODE returns a value of type NODE. Combines the features found in list and text items. 'SALARY'). Only enduser action will generate an event. ELSIF tp_lb LIKE 'Va%' THEN SET_TAB_PAGE_PROPERTY(tp_id. When the operator selects the list icon. Usage Notes • • SYSTEM. Only end-user action will generate an event.TRIGGER_NODE is the node the user clicked on. label. Usage Notes • SYSTEM. label. a vertical scroll bar appears. When-Tree-Node-Selected Trigger Fires when a node is selected or deselected. a list of available choices appears. SYSTEM. SYSTEM. 11.TRIGGER_NODE returns a value of type NODE.Shik Mahamood Ali 87 IF tp_lb LIKE 'Sa%' THEN SET_TAB_PAGE_PROPERTY(tp_id. 12. When-Tree-Node-Activated Trigger Fires when an operator double-clicks a node or presses Enter when a node is selected. The combo box list item appears as an empty box with an icon to the right. • Defining list items A list item displays a predefined set of choices that   LIST ITEM Poplist Text List are mutually exclusive can be displayed as either a poplist. text list. ELSE null.TRIGGER_NODE is the node the user clicked on. 'VACATION'). The user can enter text directly into the combo field or click the list icon to display a list of available values. No programmatic action will cause the When-Tree-Node-Selected trigger to fire. 13. When-Tree-Node-Expanded Trigger Fires when a node is expanded or collapsed. Appears as a rectangular box which displays a fixed number of values. Usage Notes • • SYSTEM.TRIGGER_NODE is the node the user clicked on. or combo box DESCRIPTION Combo Box Appears initially as a single field (similar to a text item field). the combo box style list item will display fixed values and accept one operator-entered value. END. No programmatic action will cause the When-Tree-Node-Activated trigger to fire.

Shik Mahamood Ali 88 .

Sign up to vote on this title
UsefulNot useful