This action might not be possible to undo. Are you sure you want to continue?
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.
BEGIN . END. */ Forms_DDL(my_stmt).*/ BEGIN Forms_DDL(’create table temp(n NUMBER)’). ** TEMP(COL1. COL2. END.. ELSE Message (’Table Created’). Do not end the PL/SQL block with a slash.. Enclose the PL/SQL block in a valid BEGIN/END block structure.COL’||TO_CHAR(i)||’ NUMBER’. IF NOT Form_Success THEN Message (’Table Creation Failed’). /* ** Now. ELSE Message (’Table Created’). my_stmt := my_stmt||’)’. If you • • • • • If you use FORMS_DDL to execute a valid PL/SQL block: Use semicolons where appropriate. END LOOP. END IF. are not required.. Example 2: /* ** Built–in: FORMS_DDL ** Example: The string can be an expression or variable. 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 IF. create the table. while permitted. Line breaks. IF NOT Form_Success THEN Message (’Table Creation Failed’). ** Create a table with n Number columns..N LOOP my_stmt := my_stmt||’... COLn). BEGIN my_stmt := ’create table tmp(COL1 NUMBER’. */ DECLARE procname VARCHAR2(30). FOR I in 2. Example 3: /* ** Built–in: FORMS_DDL ** Example: The statement parameter can be a block ** of dynamically created PL/SQL code.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. */ PROCEDURE Create_N_Column_Number_Table (n NUMBER) IS my_stmt VARCHAR2(2000).
’). GET_FORM_PROPERTY Returns information about the given form. End. END IF.’). END. RETURN SQL_SUCCESS. ID_NULL Returns a BOOLEAN value that indicates whether the object ID is available. END.flag = ’TRUE’ THEN procname := ’Assign_New_Employer’. ** A result of zero represents success. */ FUNCTION Do_Sql (stmt VARCHAR2. END IF .Form_Status = ’CHANGED’ THEN Message (’DO_SQL: Form has outstanding locks pending. RETURN SQL_SUCCESS. IF Check_For_Locks AND :System. Forms_DDL(’Begin ’|| procname ||’. IF Form_Success THEN RETURN SQL_SUCCESS. or called form. ELSE Message (’Employee Maintenance Successful’). check_for_locks BOOLEAN := TRUE) RETURN NUMBER IS SQL_SUCCESS CONSTANT NUMBER := 0. NEW_FORM . Forms_DDL(stmt). BEGIN IF stmt IS NULL THEN Message (’DO_SQL: Passed a null statement. IF NOT Form_Success THEN Message (’Employee Maintenance Failed’). If your application is a multi-form application. END IF. END IF. then you can call this built-in to return information about the calling form. Example 4: /* ** Built–in: FORMS_DDL ** Example: Issue the SQL statement passed in as an argument. ELSE RETURN Dbms_Error_Code. END IF.’). ELSE procname := ’Update_New_Employer’. as well as about the current.Shik Mahamood Ali 6 IF :global. ** and return a number representing the outcome of ** executing the SQL statement.
A parameter list passed to a form via NEW_FORM cannot contain parameters of type DATA_PARAMETER (a pointer to record group). The locks are still in effect when you regain control from Oracle Forms. (Post–only mode can occur when your form issues a call to another form while unposted records exist in the calling form.) query_mode Takes one of the following constants as an argument: NO_QUERY_ONLY Runs the indicated form normally. and deletes in the form. Oracle Forms keeps the higher call active and treats it as a call to the new form. allowing the operator to perform inserts. To avoid losing the locks issued by the calling form. QUERY_ONLY Runs the indicated form as a query–only form.paramlist_name ) formmodule_name Specifies the formmodule name of the called form. Oracle Forms releases memory (such as database cursors) that the terminated form was using. You cannot specify a FULL_ROLLBACK from a form that is running in post–only mode.data_mode. These locks can also occur when invoking Oracle Forms from an external 3GL program. Oracle Forms prevents any commit processing in the called form. NO_ROLLBACK Oracle Forms exits the current form without rolling back to a savepoint. NEW_FORM (formmodule_name VARCHAR2. The calling form is terminated as the parent form. If the parent form was a called form.Shik Mahamood Ali 7 Exits the current form and enters the indicated form. paramlist_id Specifies the unique ID Oracle Forms assigns when it creates the parameter list. You can leave the top level form without performing a rollback. The name must be enclosed in single quotes. rollback_mode. updates. Oracle Forms runs the new form with the same Runform options as the parent form. paramlist_name . Specify a parameter list when you want to pass parameters from the calling form to the new form. The data type of the ID is PARAMLIST. FULL_ROLLBACK Oracle Forms rolls back all uncommitted changes (including posted changes) that were made during the current Runform session. Oracle Forms runs the new form with the same options as the parent form.query_mode. If the calling form had been called by a higher form. which means that you retain any locks across a NEW_FORM operation. The data type of the name is CHAR. rollback_mode TO_SAVEPOINT Oracle Forms rolls back all uncommitted changes (including posted changes) to the current form’s savepoint.
allowing the operator to query. CALL_FORM. paramlist_id . The data type of the name is CHAR. but not to insert. NO_HIDE Causes Oracle Forms to display the called form without clearing the calling form from the screen. updates. update. The name must be enclosed in single quotes.Shik Mahamood Ali 8 The name you gave the parameter list object when you defined it. CALL_FORM (formmodule_name VARCHAR2. or delete records. data_mode NUMBER. Oracle Forms runs the called form with the same Runform preferences as the parent form. Runs an indicated form while keeping the parent form active. 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. 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. HIDE is the default parameter. display NUMBER. allowing the operator to perform inserts. query_mode NUMBER. 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. QUERY_ONLY Causes Oracle Forms to run the indicated form in Query Only mode. 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. switch_menu NUMBER. Parameters: formmodule_name Specifies the formmodule name of the called form. DO_REPLACE Causes Oracle Forms to replace the default menu application of the calling form with the default menu application of the called form. paramlist_name VARCHAR2). The data type of the name is CHAR. and deletes from within 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).
NO_ACTIVATE Opens the form but does not set focus to the form. Call OPEN_FORM to create multiple–form applications.NO_HIDE.session_mode. The current form remains current. .paramlist_id). paramlist_name The name you gave the parameter list object when you defined it. You can optionally include a parameter list as initial input to the called form. Use the GET_PARAMETER_LIST function to return the ID to a variable of type PARAMLIST. activate_mode ACTIVATE Sets focus to the form to make it the active form in the application.QUERY_ONLY).session_mode.activate_mode. that is. Call_Form(’lookcust’. paramlist_id PARAMLIST). SESSION Specifies that a new. session_mode NO_SESSION Specifies that the opened form should share the same database session as the current form. paramlist_id Specifies the unique ID that Oracle Forms assigns to the parameter list at the time it is created. A COMMIT operation in any form will cause validation and commit processing to occur for all forms running in the same session. session_mode NUMBER. form_name.paramlist_name).session_mode). The data type of the name is CHAR. data_mode NUMBER. form_name. OPEN_FORM (form_name VARCHAR2. separate database session should be created for the opened form. form_name. applications that open more than one form at the same time.DO_REPLACE. form_name Specifies the CHAR name of the form to open.activate_mode). OPEN_FORM Opens the indicated form. form_name.activate_mode. paramlist_name Specifies the CHAR name of a parameter list to be passed to the opened form.activate_mode. OPEN_FORM( OPEN_FORM( OPEN_FORM( OPEN_FORM( OPEN_FORM( REPLACE_MENU form_name). The data type of the ID is PARAMLIST. activate_mode NUMBER.Shik Mahamood Ali 9 Specifies the unique ID Oracle Forms assigns when it creates the parameter list.
PROCEDURE STORE_FORMNAME IS BEGIN :GLOBAL.Form_Status = ’CHANGED’THEN Commit_Form. The value is always a character string. tm_name := Get_Application_Property(TIMER_NAME). The value can be one of three character strings: CHANGED Indicates that the form contains at least one block with a Changed record. value).SYSTEM.Calling_Form := :System. Syntax: SET_FORM_PROPERTY( formmodule_id. property. Example 2: /* ** Built–in: GET_APPLICATION_PROPERTY ** Example: Capture the username and password of the ** currently logged–on user. You must call this built–in once for each value you want to retrieve. END. the_connect IN OUT VARCHAR2) IS BEGIN the_username := Get_Application_Property(USERNAME). .FORM_STATUS represents the status of the current form. property. */ PROCEDURE Get_Connect_Info( the_username IN OUT VARCHAR2. SYSTEM. the_connect := Get_Application_Property(CONNECT_STRING).Current_Form. SET_FORM_PROPERTY( formmodule_name. value).System Variables 1. NEW QUERY IF :System. END. the_password IN OUT VARCHAR2. SET_FORM_PROPERTY Sets a property of the given form. 2.Shik Mahamood Ali 10 Replaces the current menu with the specified menu. The form contains at least one block with QUERY records and no blocks with CHANGED records.CURRENT_FORM SYSTEM. but does not make the new menu active.CURRENT_FORM represents the name of the form that Form Builder is executing. Indicates that the form contains only New records. REPLACE_MENU also allows you to change the way the menu displays and the role. The value of SYSTEM. Indicates that a query is open. Description: The GET_APPLICATION_PROPERTY built–in returns information about the current Oracle Forms application. the_password := Get_Application_Property(PASSWORD). Form. for use in calling ** another Tool.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.
displaying and manipulating records. 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. A detail block displays detail records associated with a master record displayed in master block. SYSTEM. Data blocks can be based on database tables. the association between a data block and the database allows operators to automatically query. Enter Query. In addition.MODE indicates whether the form is in Normal. MODE 11 SYSTEM. It provides a mechanism for grouping related items into a functional unit for storing. or transactional triggers. BLOCKS Block is logical owner of items. . END IF. 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. /* ** When–New–Item–Instance Trigger */ BEGIN IF :System. END. meaning that a query is currently being processed. 3. A multi-record block displays more than one record at a time. End if. 2. The following trigger accomplishes that operation. Control Blocks A control block is not associated with the database. insert. and the items in a control block do not relate to table columns within a database. Clear_Form. procedures. Data Blocks Data blocks are associated with data (table columns) within a database. The value is always a character string. All blocks are either single-record or multi-record blocks: A single-record block displays one record at a time.EMPNO’ and :System. Indicates that the form is currently in fetch processing mode. NORMAL ENTER-QUERY QUERY Indicates that the form is currently in normal processing mode. views. and delete rows within a database. or Fetch Processing mode. Indicates that the form is currently in Enter Query mode. Types of Blocks 1.Cursor_Item = ’EMP. update.Mode = ’ENTER–QUERY’ THEN IF NOT Show_Lov(’my_lov’) THEN RAISE Form_Trigger_Failure.Shik Mahamood Ali END IF. By default.
END IF. . committing the changes. or prompting the end user. */ DECLARE prev_blk VARCHAR2(40) := :System. 3. 2. GET_BLOCK_PROPERTY( block_name. IF :System. END. and flushes the current block without 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. You must issue a call to the built-in once for each property value you want to retrieve. NO_VALIDATE Form Builder flushes the current block without validating the changes." the current block.Shik Mahamood Ali Block Built . or "flush. CLEAR_BLOCK built-in Causes Form Builder to remove all records from. property). You must define an appropriately typed variable to accept the return value. GET_BLOCK_PROPERTY Returns information about a specified block. Example: /* ** Built–in: BLOCK_MENU ** Example: Calls up the list of blocks in the form when the ** user clicks a button. Define the variable with a type of Block. performs a commit. property). and prints a message if ** the user chooses a new block out of the list to ** which to navigate. 4.Cursor_Block. BEGIN BLOCK_MENU. Clear_Block(No_Validate).Cursor_Block <> prev_blk THEN Message(’You successfully navigated to a new block!’). Form Builder sets the input focus to the first enterable item in the block you select from the LOV. DO_COMMIT Form Builder validates the changes.ins 1. FIND_BLOCK Searches the list of valid blocks and returns a unique block ID. NO_COMMIT Form Builder validates the changes and flushes the current block without performing a commit or prompting the end user. BLOCK_MENU built-in 12 Displays a list of values (LOV) containing the sequence number and names of valid blocks in your form. Syntax: GET_BLOCK_PROPERTY( block_id.
Syntax: SET_BLOCK_PROPERTY( block_id.PROPERTY_FALSE). ID_NULL Returns a BOOLEAN value that indicates whether the object ID is available. an error occurs.Shik Mahamood Ali 13 ** Determine the (1) Current Record the cursor is in.UPDATE_ALLOWED. Example: /* ** Built–in: SET_BLOCK_PROPERTY ** Example: Prevent future inserts. ** (2) Current Record which is visible at the ** first (top) line of the multirecord ** block. BEGIN /* Lookup the block’s internal ID */ blk_id := Find_Block(blk_name). Set_Block_Property(blk_id.INSERT_ALLOWED.SET_BLOCK_PROPERTY Sets the given block characteristic of the given block. */ cur_rec := Get_Block_Property( bk_id. property.PREVIOUS_BLOCK Navigates to the first navigable item in the previous enterable block in the navigation sequence 9.PROPERTY_FALSE). property. top_rec := Get_Block_Property( bk_id. GO_BLOCK GO_BLOCK navigates to an indicated block. TOP_RECORD). 7. Set_Block_Property(blk_id. */ IF NOT Id_Null(blk_id) THEN Set_Block_Property(blk_id. NEXT_BLOCK Navigates to the first navigable item in the next enterable block in the navigation sequence 8. ELSE .PROPERTY_FALSE). value). */ PROCEDURE Make_Block_Query_Only( blk_name IN VARCHAR2 ) IS blk_id Block.DELETE_ALLOWED. value). and deletes to ** queried records in the block whose name is ** passed as an argument to this procedure. updates. 6. 5. /* ** If the block exists (ie the ID is Not NULL) then set ** the three properties for this block. If the target block is non-enterable . CURRENT_RECORD). SET_BLOCK_PROPERTY( block_name. Otherwise signal ** an error.
and Post. END.Item.and Post-Form triggers). or item (as in the Pre. 2. record. IF :System. The value is always a character string. or the current data block during trigger processing.CURRENT_BLOCK is the name of the block that Form Builder is processing or that the cursor is in. END IF. and Block triggers). Indicates that the block contains only New records. Block .SYSTEM.CURRENT_BLOCK The value that the SYSTEM. Indicates that the block contains only Valid records that have been retrieved from the database.System Variables 1.and Post. RAISE Form_Trigger_Failure. and Block triggers). The following Key–CLRBLK trigger performs this function.CURSOR_BLOCK is NULL.CURSOR_BLOCK system variable represents depends on the current navigation unit: If the current navigation unit is the block.BLOCK_STATUS represents the status of a Data block where the cursor is located.Block_Status = ’CHANGED’ THEN Commit_Form.CURRENT_BLOCK system variable represents depends on the current navigation unit: If the current navigation unit is the block.and Post-Form triggers). Clear_Block.CURSOR_BLOCK The value that the SYSTEM.SYSTEM. the value of SYSTEM. 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. the value of SYSTEM. record. If the current navigation unit is the form (as in the Pre. If the current navigation unit is the form (as in the Pre. 3.BLOCK_STATUS SYSTEM.Shik Mahamood Ali 14 Message(’Block ’||blk_name||’ does not exist. Record.’). .Item. or item (as in the Pre. the value of SYSTEM.CURRENT_BLOCK is NULL. The value can be one of three character strings: CHANGED NEW QUERY Indicates that the block contains at least one Changed record. the value of SYSTEM. Record.CURSOR_BLOCK is the name of the block where the cursor is located. END IF.SYSTEM.
SYSTEM. Go_Block(Name_In(’System.Trigger_Block’)). END. END IF. 4. 5. IF curblk = ’ORDERS’ THEN Go_Block(’ITEMS’). ELSIF curblk = ’ITEMS’ THEN Go_Block(’CUSTOMERS’). When-Clear-Block. 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.TRIGGER_BLOCK represents the name of the block where the cursor was located when the current trigger initially fired. The value is always a character string. 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. and the detail data block is based on the table with the foreign key. ELSIF curblk = ’CUSTOMERS’ THEN Go_Block(’ORDERS’). What Is a Relation? . The value is NULL if the current trigger is a Pre.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. using :SYSTEM. BEGIN curblk := :System. The following statement performs this function. The master data block is based on the table with the primary key.COORDINATION_OPERATION to help an On-Clear-Details trigger determine what type of coordination-causing operation fired the trigger.Cursor_Block.MASTER_BLOCK This system variable works with its companion SYSTEM. Block – Based Triggers [Block Processing Trigger] When-Create-Record. When-Database-Record. The following trigger performs this function. A master-detail relationship equates to the one-tomany relationship in the entity relationship diagram. SYSTEM. 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.CURSOR_BLOCK stored in a local variable. and on which master block of a master/detail relation. DECLARE curblk VARCHAR2(30).TRIGGER_BLOCK SYSTEM.or Post-Form trigger.
Master Deletes You can prevent. or isolate deletion of a record in a master block when corresponding records exist in the detail block by setting the Master Deletes property. propagate. you can create your own by setting the properties in the New Relation dialog box. Like implicitly created relations. Explicit Relations If a relation is not established when default blocks are created. This relation is named masterblock_detailblock. For example. • 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 . S_ORD_S_ITEM. for example.Shik Mahamood Ali 16 A relation is a Form Builder object that handles the relationship between two associated blocks. 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. PL/SQL program units and triggers are created automatically when you explicitly create a relation. 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. 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. a relation is automatically created.Delete trigger.
data types.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. Query record group A query record group is a record group that has an associated SELECT statement. Static record group . 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. Oracle Forms does not automatically fetch the detail records. (Deferred False. Non-query record groups can be created and modified only at runtime. the operator must navigate to the detail data block and explicitly execute a query. the detail records are fetched immediately. Query record groups can be created and modified at design time or at runtime. Auto-Query False) Deferred with Auto Query Oracle Forms defers fetching the associated detail records until the operator navigates to the detail data block. For example. On-Populate-Details. Deferred Without Auto Query When coordination-causing event occurs. When a coordination-causing event occurs. and lengths from the database columns referenced in the SELECT statement. Default [Immediate] The default setting. 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. To fetch the detail records. 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. The columns in a query record group derive their default names. you can defer querying the line items for an order until the operator navigates to the item block. but whose structure and values can be modified programmatically at runtime. Non-query record group A non-query record group is a group that does not have an associated query. The records in a query record group are the rows retrieved by the query associated with that record group.
and they remain fixed at runtime. row_number NUMBER. Record Group built-in subprograms Creating and deleting groups: A] CREATE_GROUP (recordgroup_name VARCHAR2. DELETE_GROUP_ROW (recordgroup_id RecordGroup. you define its structure and row values at design time. .row_number NUMBER. Deletes a programmatically created record group.Shik Mahamood Ali 18 A static record group is not associated with a query. Modifying a group's structure: ADD_GROUP_COLUMN (recordgroup_name VARCHAR2. POPULATE_GROUP returns a 0 (zero). ADD_GROUP_ROW (recordgroup_name VARCHAR2. Sets the value for the record group cell identified by the given row and column. scope NUMBER. Creates a record group with the given name. instead. The record group is cleared and rows that are fetched replace any existing rows in the record group. When rows are deleted. Upon a successful query. SET_GROUP_CHAR_CELL(groupcolumn_id GroupColumn. Static record groups can be created and modified only at design time. the appropriate memory is freed and available to Form Builder. query VARCHAR2. The rows that are retrieved as a result of a successful query replace any rows that exist in the group.column_type NUMBER. The record group has columns representing each column you include in the select list of the query C] DELETE_GROUP (recordgroup_name VARCHAR2). scope NUMBER. row_number NUMBER) Deletes the indicated row or all rows of the given record group. Populating Groups: POPULATE_GROUP (recordgroup_id RecordGroup). Form Builder automatically decrements the row numbers of all rows that follow a deleted row. column_width NUMBER) Adds a column of the specified type to the given record group. POPULATE_GROUP_WITH_QUERY (recordgroup_id RecordGroup. array_fetch_size NUMBER) Creates a non-query record group with the given name B] CREATE_GROUP_FROM_QUERY (recordgroup_name VARCHAR2.cell_value VARCHAR2) Sets the value for the record group cell identified by the given row and column. Executes the query associated with the given record group and returns a number indicating success or failure of the query. groupcolumn_name VARCHAR2. array_fetch_size NUMBER). SET_GROUP_DATE_CELL (groupcolumn_id GroupColumn. cell_value DATE). row_number Adds a row to the given record group. An unsuccessful query generates an ORACLE error number that corresponds to the particular SELECT statement failure. query VARCHAR2) Populates a record group with the given query. NUMBER).
A cell is an intersection of a row and column. NUMBER_COLUMN). gc_id GroupColumn. row_number NUMBER. NUMBER_COLUMN). rg_id RecordGroup.Shik Mahamood Ali 19 SET_GROUP_NUMBER_CELL(groupcolumn_id GroupColumn.cell_value NUMBER). /* ** Populate group with a query */ . Define the variable with a type of RecordGroup. BEGIN /* ** Make sure the record group does not already exist.*/ DECLARE rg_name VARCHAR2(40) := ’Salary_Range’. create it and add the two ** necessary columns to it. Searches the list of record groups and returns a record group ID when it finds a valid group with the given name. /* Add two number columns to the record group */ gc_id := Add_Group_Column(rg_id. ’Emps_In_Range’. 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). END IF. You must define an appropriately typed variable to accept the return value. */ rg_id := Find_Group(rg_name). row_number NUMBER). errcode NUMBER. /* ** If it does not exist. Returns the VARCHAR2 or LONG value for a record group cell identified by the given row and column. gc_id := Add_Group_Column(rg_id. FIND_COLUMN (function) Example: /* ** Built–in: CREATE_GROUP ** Example: Creates a record group and populates its values ** from a query. ’Base_Sal_Range’. Sets the value for the record group cell identified by the given row and column. Getting cell values: GET_GROUP_CHAR_CELL (groupcolumn_id GroupColumn. */ IF Id_Null(rg_id) THEN rg_id := Create_Group(rg_name).
Shik Mahamood Ali 20 errcode := Populate_Group_With_Query( rg_id. . when the end user navigates to a text item with an associated LOV. as long as the input focus is in a text item that has an attached LOV. GET_LOV_PROPERTY (lov_id. SHOW_LOV( lov_id. ’SELECT SAL–MOD(SAL. y). property LOV). x. IF NOT a_value_chosen THEN Message(’You have not selected a value. The list of values remains displayed until the operator dismisses the LOV or selects a value. Ø At design time. 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. LOV Built-in subprograms 1. Ø LOV auto-reduction and search features allow end users to locate specific values. 2. END. SHOW_LOV( lov_id). independent of any specific text item. Ø LOV values that are selected by the end user can be assigned to form items according to the return items you designate. END IF. Ø LOV values are derived from record groups. RAISE Form_Trigger_Failure. an LOV can be attached to one or more text items in the form. Example: /* ** Built–in: SHOW_LOV ** Example: Display a named List of Values (LOV) */ DECLARE a_value_chosen BOOLEAN. LOV Properties 1. x.1000) ’ ||’ORDER BY 1’). SHOW_LOV( lov_name). SHOW_LOV( lov_name.1000). 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. Bell.SHOW_LOV Displays a list of values (LOV) window at the given coordinates. or programmatically. and returns TRUE if the operator selects a value from the list. y). BEGIN a_value_chosen := Show_Lov(’my_employee_status_lov’).COUNT(EMPNO) ’ ||’FROM EMP ’ ||’GROUP BY SAL–MOD(SAL. and FALSE if the operator Cancels and dismisses the list.
Validation from Lov to text item.'new_group'). property NUMBER. 12. SET_LOV_COLUMN_PROPERTY (lov_id NUMBER. . 6. 3. LOV. When Automatic Skip is set to No.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.GROUP_NAME. the LOV remains displayed. In this dialog box any value can be entered. Sets the given LOV property for the given LOV.GROUP_NAME Specifies the name of the record group on which an LOV is based. from this value entered the where clause constructed. When this property is true a dialog box appear. the focus remains in the text item after the operator makes a selection from the LOV.Column Mapping This property is used to specify the return item.colnum NUMBER. Key-LISTVAL Trigger: List_Values.>If it is not specified then value from Lov cannot assigned to the block. SET_LOV_COLUMN_PROPERTY Sets the given LOV property for the given LOV. 7. value NUMBER). When Automatic Confirm is set to No. 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 . SET_LOV_PROPERTY(lov_id LOV. 4.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. property 5. giving the operator the option to explicitly select the remaining choice or dismiss the LOV. Long List It is used to append a ‘ where clause ‘ to the select statement. 9.value VARCHAR2).Shik Mahamood Ali 21 Returns information about a specified list of values (LOV). 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.Automatic Refresh property Determines whether Form Builder re-executes the query to populate an LOV that is based on a query record group. 11. 2. the LOV is dismissed automatically and column values from the single row are assigned to their corresponding return items. Set_LOV_Property('my_lov'. 10. 8.Title property Specifies the title to be displayed for the object.
The actual parameter can be either a parameter list ID of type PARAMLIST.id IS NULL THEN Go_Item ('customer. either by list ID or name. key 4. END IF. paramtype VARCHAR2. DELETE_PARAMETER (list VARCHAR2. The name of the parameter. Text Parameter It is passed between forms. In the following example. The value of the text parameter is a character string. ADD_PARAMETER (list VARCHAR2. It can also passed between different oracle products. key VARCHAR2) Deletes the parameter with the given key from the parameter list. but before Form Builder returns to the normal event sequence. as written. or the VARCHAR2 name of the parameter list.id'). 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. and an associated value. Data type – char – 2555 char maximum Global variables are visible across multiple forms Parameter values are not visible across multiple forms. list or name . an IF statement is added to the previous trigger: Key-LISTVAL Trigger: List_Values. Creates a parameter list with the given name. key VARCHAR2. using a Key-LISTVAL trigger allows you to add subsequent PL/SQL statements that execute after the LOV is displayed. 2.PROCEDURE DESTROY_PARAMETER_LIST (list VARCHAR2) Deletes a dynamically created parameter list and all parameters it contains. Adds parameters to a parameter list. IF :customer.Shik Mahamood Ali 22 This trigger. Data Parameter It is name of the record group present in the current form. key VARCHAR2. It is passed between oracle products. Types 1. GET_PARAMETER_ATTR (list VARCHAR2. Parameter – Built Ins 1. Returns the current value and type of an indicated parameter in an indicated parameter list. 2.CREATE_PARAMETER_LIST (name VARCHAR2). 3. Each parameter consists of a key. The data type of the key is VARCHAR2. VARCHAR2). But not between forms.value VARCHAR2). is of little value since it merely duplicates default Form Builder functionality. list or name Specifies the parameter list. paramtype NUMBER. 5. However. its type.
display). document. RUN_PRODUCT built-in Invokes one of the supported Oracle tools products and specifies the name of the module or module to be run. commmode.name. and cannot be an expression. Key The VARCHAR2 name of the parameter.SET_PARAMETER_ATTR (list PARAMLIST. report.list. If the parameter is a text parameter. display). SYNCHRONOUS specifies that control returns to Oracle Forms only after the called product has been exited. location. the value is the name of a record group. If the parameter is a data type parameter. Value An OUT parameter of type VARCHAR2. Paramtype An OUT parameter of type NUMBER. ASYNCHRONOUS specifies that control returns to the calling application immediately. Form Builder returns a message to the end user. Valid values are the name of a form module. the value is an actual text parameter. BOOK specifies Oracle Book. commmode Specifies the communication mode to be used when running the called product. REPORTS specifies Oracle Reports. The actual parameter can be either a parameter list ID of type PARAMLIST. GRAPHICS specifies Oracle Graphics. If the called product is unavailable at the time of the call. The application looks for the module or document in the default paths defined for the called product. Valid numeric constants for this parameter are SYNCHRONOUS and ASYNCHRONOUS. 6. The operator cannot work in the form while the called product is running. TEXT_PARAMETER Indicates that the parameter's value is an actual data value.Shik Mahamood Ali 23 Specifies the parameter list to which the parameter is assigned. paramtype NUMBER) Sets the type and value of an indicated parameter in an indicated parameter list. or Oracle Book document. commmode. even if the called application has not completed its display. document. Oracle Graphics display. location. or the VARCHAR2 name of the parameter list. RUN_PRODUCT( product. execmode. The actual parameter you supply must be a variable of type NUMBER. key VARCHAR2. execmode . product Specifies a numeric constant for the Oracle product you want to invoke: FORMS specifies a Runform session. 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. document Specifies the CHAR name of the document or module to be executed by the called product. execmode. Syntax: RUN_PRODUCT( product.
*/ IF NOT Id_Null(pl_id) THEN Destroy_Parameter_List( pl_id ). Note: You cannot pass a DATA_PARAMETER to a child query in Oracle Reports. either the file system or the database. When you run Oracle Forms. ** Presumes the Emp_Recs record group already ** exists and has the same column/data type ** structure as the report’s Emp_Query query. 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. The name of the chart item must be specified in the format block_name. Valid values for this parameter are the CHAR name of the parameter list. bar chart.Shik Mahamood Ali 24 Specifies the execution mode to be used when running the called product. When you run Oracle Reports and Oracle Graphics. always set execmode to RUNTIME. passing the ** data in record group ’EMP_RECS’ to substitute ** for the report’s query named ’EMP_QUERY’.) Note: You can pass text parameters to called products in both SYNCHRONOUS and ASYNCHRONOUS mode. execmode can be either BATCH or RUNTIME. To specify a parameter list ID. then delete it before we create it again in ** case it contains parameters that are not useful for our ** purposes here. However. .5 report. use a variable of type PARAMLIST. (This parameter is only required when you are using an Oracle Graphics chart item in a form. location Specifies the location of the document or module you want the called product to execute. Valid numeric constants for this parameter are BATCH and RUNTIME. (SYNCHRONOUS mode is required when invoking Oracle Graphics to return an Oracle Graphics display that will be displayed in a form chart item. Example: /* ** Built–in: RUN_PRODUCT ** Example: Call an Oracle Reports 2. or graph) generated by Oracle Graphics. /* ** If it does. or NULL. display Specifies the CHAR name of the Oracle Forms chart item that will contain the display (such as a pie chart. */ pl_id := Get_Parameter_List(’tmpdata’).) 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. */ PROCEDURE Run_Emp_Report IS pl_id ParamList. BEGIN /* ** Check to see if the ’tmpdata’ parameter list exists.item_name. list or name Specifies the parameter list to be passed to the called product. the ID of the parameter list. Data passing is supported only for master queries. Valid constants for this property are FILESYSTEM and DB.
END IF. */ BEGIN . ’dept_recordgroup’).’EMP_RECS’). ’dept_query’. Signal an error ** if the list already exists or if creating the ** list fails.’number_of_copies’.DATA_PARAMETER. IF Id_Null(pl_id) THEN pl_id := Create_Parameter_List(pl_name). First ** make sure the list does not already exist. IF NOT Id_Null(pl_id) THEN Add_Parameter(pl_id. Example: /* ** Built–in: ADD_PARAMETER ** Example: Add a value parameter to an existing Parameter ** List ’TEMPDATA’. */ DECLARE pl_id ParamList. pl_name VARCHAR2(10) := ’tempdata’. /* ** Run the report synchronously. SYNCHRONOUS. Example: /* ** Built–in: DELETE_PARAMETER ** Example: Remove the ’NUMBER_OF_COPIES’ parameter from the ** already existing ’TEMPDATA’ parameter list. Example: /* ** Built–in: CREATE_PARAMETER_LIST ** Example: Create a parameter list named ’TEMPDATA’.FILEYSTEM. RUNTIME. and the record group named ** ’EMP_RECS’ in the form. END IF. then add a data parameter to ** the list to associate named query ’DEPT_QUERY’ ** with record group ’DEPT_RECORDGROUP’. DATA_PARAMETER. */ pl_id := Create_Parameter_List(’tmpdata’).’EMP_QUERY’. END.Shik Mahamood Ali END IF. END IF.TEXT_PARAMETER. ELSE Message(’Parameter list ’||pl_name||’ already exists!’). */ DECLARE pl_id ParamList. IF Id_Null(pl_id) THEN Message(’Error creating parameter list ’||pl_name). pl_id. NULL). END. */ Add_Parameter(pl_id. passing the parameter list */ Run_Product(REPORTS. ’empreport’. /* ** Add a data parameter to this parameter list that will ** establish the relationship between the named query ** ’EMP_QUERY’ in the report.’19’). 25 /* ** Create the ’tmpdata’ parameter list afresh. END. BEGIN pl_id := Get_Parameter_List(pl_name). then ** attempt to create a new list. BEGIN pl_id := Get_Parameter_List(’tempdata’). Add_Parameter(pl_id. RAISE Form_Trigger_Failure. RAISE Form_Trigger_Failure.
BEGIN pl_id := Get_Parameter_List(’tempdata’). /* ** If there is a Non–NULL Last Where clause to ** pass. END. –– BATCH. wc VARCHAR2(2000). TEXT_PARAMETER. End. –– FILESYSTEM. IF NOT Id_Null(pl_id) THEN Destroy_Parameter_List(pl_id). /* ** Get the Where Clause from the Last Query ** using a user–defined function */ wc := Last_Where_Clause. /* ** Launch the report. Example 2: PROCEDURE Run_Report_For_Last_Query IS pl ParamList.’number_of_copies’). –– SYNCHRONOUS. Referencing Form Builder items indirectly 1. Example: /* ** Built–in: DESTROY_PARAMETER_LIST ** Example: Remove the parameter list ’tempdata’ after first ** checking to see if it exists */ DECLARE pl_id ParamList. */ Run_Product(REPORTS. END IF. –– ’rep0058. ’the_Where_Clause’. –– pl ). END IF. add a text parameter to the parameter ** list to specify the parameter name and its ** value.Shik Mahamood Ali 26 Delete_Parameter(’tempdata’.rdf’.NAME_IN 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 . –– The Where Clause to Pass BEGIN /* ** Create a parameter list for parameter passing */ pl := Create_Parameter_List(’tmp’). –– /* Delete the parameter list */ Destroy_Parameter_List(pl). wc ). */ IF wc IS NOT NULL THEN Add_Parameter(pl. In this case the report definition has ** a parameter named ’the_Where_Clause’ that ** it’s expecting. passing parameters in the ** parameter list. END.
and PostItem. SYSTEM. If the current navigation unit is the form (as in the Pre.a’). The value can be one of three character strings: CHANGED NEW QUERY Indicates that the block contains at least one Changed record.CURRENT_BLOCK is the name of the block that Form Builder is processing or that the cursor is in. SYSTEM.System Variable It is used to track of runtime status condition. COPY(NAME_IN(source). Record. System Variable 1. the .direct reference IF NAME_IN('emp. VARIABLES It is used to store values from form items.indirect reference 2. 'Emp.COORDINATION_OPERATION This system variable works with its companion SYSTEM.and Post-Form triggers). and on which master block of a master/detail relation. destination). Use the NAME_IN function to get the value of an item without referring to the item directly.Global Variable Whose value is accessible to trigger and subprograms in any modules – limit – 255 char length 3. Copy( cur_val.SYSTEM. record. the value of SYSTEM.ename = 'smith' -. 2.BLOCK_STATUS SYSTEM. or item (as in the Pre.Empno' ). Indicates that the block contains only Valid records that have been retrieved from the database. or the current data block during trigger processing.Local Variables The local variable is PL/SQL variable whose value is only accessible with in the trigger or user named sub Programs 2. 3. Indicates that the block contains only New records. 1.CURRENT_BLOCK system variable represents depends on the current navigation unit: If the current navigation unit is the block.COPY built-in Copies a value from one item or variable into another item or global variable.BLOCK_STATUS represents the status of a Data block where the cursor is located.MASTER_BLOCK to help an OnClear-Details trigger determine what type of coordination-causing operation fired the trigger.CURRENT_BLOCK s The value that the SYSTEM. and Block triggers). cur_val VARCHAR2(40). Destroy global variable - erase(‘global.Shik Mahamood Ali 27 The NAME_IN function returns the contents of an indicated variable or item.ename') = 'smith' -. IF :emp.
12. The value can be one of three character strings: CHANGED Indicates that the form contains at least one block with a Changed record. The value is always a character string. The value is always a character string. Indicates that the form contains only New records.CURSOR_VALUE SYSTEM.MASTER_BLOCK This system variable works with its companion SYSTEM. SYSTEM.Details trigger determine what type of coordination-causing operation fired the trigger.LAST_QUERY SYSTEM.MODE s SYSTEM. SYSTEM. SYSTEM.FORM_STATUS SYSTEM.CURSOR_ITEM SYSTEM. .FORM_STATUS represents the status of the current form. The form contains at least one block with QUERY records and no blocks with CHANGED records. Indicates that a query is open.CURSOR_ITEM represents the name of the block and item. 6. 4. The value is always a character string.LAST_QUERY represents the query SELECT statement that Form Builder most recently used to populate a block during the current Runform session. item. SYSTEM. NORMAL ENTER-QUERY Indicates that the form is currently in normal processing mode. SYSTEM.MODE indicates whether the form is in Normal. The value is a CHAR string in the following format: DD-MON-YYYY HH24:MM:SS 5. Enter Query.CURSOR_RECORD represents the number of the record where the cursor is located.COORDINATION_OPERATION to help an On-Clear.CURRENT_FORM represents the name of the form that Form Builder is executing. or Fetch Processing mode. 11. The value is always a character string.CURSOR_VALUE represents the value of the item where the cursor is located. where the input focus (cursor) is located.Shik Mahamood Ali 28 value of SYSTEM. This number represents the record's current physical order in the block's list of records. block. The value of SYSTEM.CURRENT_FORM SYSTEM. and on which master block of a master/detail relation.CURRENT_DATETIME is a variable representing the operating system date. 9. NEW QUERY 10. Indicates that the form is currently in Enter Query mode. 7.CURRENT_BLOCK is NULL.CURRENT_DATETIME SYSTEM. The value is always a character string.FORM_STATUS becomes CHANGED only after at least one record in the form has been changed and the associated navigation unit has also changed. SYSTEM.CURSOR_RECORD SYSTEM. SYSTEM. SYSTEM. SYSTEM. 8. The value is always a character string.
For example. There are 2 ways to creating property class a. and pattern properties that you set for form and menu objects that appear in your application's interface. 14.MOUSE_ITEM If the mouse is in an item. meaning that a query is currently being processed.MOUSE_ITEM is NULL if: Ø the mouse is not in an item Ø the operator presses the left mouse button. Indicates that the record's validation status is Valid and that it was retrieved from the database. When referenced in a key trigger. An object based on a property class can inherit the settings of any property in the class that is appropriate for that object. 13.MOUSE_ITEM represents the name of that item as a CHAR value. SYSTEM. PROPERTY CLASS This object is a named object that contains a list of properties and their associated settings. Indicates that the record's validation status is Changed and that the record does not exist in the database. Indicates that the record's validation status is New.TRIGGER_BLOCK represents the name of the block where the cursor was located when the current trigger initially fired. SYSTEM.TRIGGER_ITEM represents the item (BLOCK. Property Window method Property class can not be change programmatically.RECORD_STATUS SYSTEM.ITEM1. then moves the mouse Ø the platform is not a GUI platform. the value for SYSTEM.TRIGGER_ITEM SYSTEM. SYSTEM. VISUAL ATTRIBUTES Visual attributes are the font.Shik Mahamood Ali QUERY 29 Indicates that the form is currently in fetch processing mode. Once you create a property class you can base other objects on it. b. The value is always a character string.MOUSE_ITEM is :BLOCK2. 16. SYSTEM. 15. The value is always a character string. The value can be one of four character strings: CHANGED INSERT NEW QUERY Indicates that a queried record's validation status is Changed.or Post-Form trigger.TRIGGER_BLOCK SYSTEM. SYSTEM. SYSTEM. The value is NULL if the current trigger is a Pre.ITEM) in the scope for which the trigger is currently firing. if the mouse is in Item1 in Block2. The Property Palette is where you set the properties of objects you create in form and menu modules. Object Navigator method. color.RECORD_STATUS represents the status of the record where the cursor is located. Visual attributes can include the following properties: . it represents the item where the cursor was located when the trigger began.
system editor. Custom When the attribute of an objects are changed at design tome. The actual settings are determined by a combination of factors. the individual attribute settings reflect the current system defaults. and the window manager. A named visual attribute is a separate object in a form or menu module that defines a collection of visual attribute properties. Font Style.EXE 2.Shik Mahamood Ali 30 Font properties: Font Name. Font Size. x. refer to the Form Builder documentation for your operating system. message_in. Visual Attribute Types 1. 2. Background Color Fill Pattern. or when you want to specify custom editor attributes such as scroll bar and title. SHOW_EDITOR(editor_name. 3. When Visual Attribute Group is set to Default. The SHOW_EDITOR procedure displays a user-named editor at the specified display coordinates. 1. Font Weight Color and pattern properties: Foreground Color. There are three types of editor objects: default editor. FORMS60_EDITOR = C:\WINDOWS\NOTEPAD. SHOW_EDITOR takes message_in and message_out parameters that . result). including the type of object. 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. Charmode Logical Attribute. White on Black It can be changed dynamically. Font Width. and user-named editor. y. Default Setting the Visual Attribute Group property to Default specifies that that the object should be displayed with default 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. the resource file in use. pattern. You create a user-named editor when you want to display the editor programmatically with SHOW_EDITOR.current_record_attribute. and font settings. they are custom VAT 3. Default Editor Default editor is invoked at runtime. For information on environment variables and system editor availability. EDITOR This object enables the operator to edit text. much like styles in a word processing program. User-Named Editor A user-named editor has the same text editing functionality as the default editor. The editor specified must use the ASCII text format. Once you create a named visual attribute. Visual attribute name is connected to an object by setting visual attribute name property Set_item_property(‘text1’. System Editor The system editor to be used is defined by the FORMS60_EDITOR environment variable. you can apply it to any object in the same module.’v1’). message_out.
IF Get_Menu_Item_Property(mi_id. END IF. IF itm_x_pos > 40 THEN Edit_TextItem(1. */ DECLARE itm_x_pos NUMBER. Show_Editor( ed_id. END IF.1.comments. ELSE ed_name := ’my_editor1’. END IF.8). The EDIT_TEXTITEM procedure invokes the editor associated with the current text item in the form (the default editor. or the current system editor).comments := val. END. Pass the contents of the :emp. mi_id MenuItem. */ DECLARE ed_id Editor. a user-named editor. ed_name VARCHAR2(40). */ val := :emp. BEGIN mi_id := Find_Menu_Item(’PREFERENCES. IF ed_ok THEN :emp.8).14. Example: /* ** Built–in: SHOW_EDITOR ** Example: Accept input from the operator in a user–defined ** editor. y.Cursor_Item. ELSE Edit_TextItem(60.14) on the ** screen. val.CHECKED) = ’TRUE’ THEN ed_name := ’system_editor’.20. . /* ** Show the appropriate editor at position (10. height). ed_ok BOOLEAN. BEGIN itm_x_pos := Get_Item_Property(:System. ed_id := Find_Editor( ed_name ). 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.SYSTEM_EDITOR’).1. val.Shik Mahamood Ali 31 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.X_POS).comments item ** into the editor and reassign the edited contents if ** ’ed_ok’ returns boolean TRUE. Use the system editor if the user has ** checked the ”System_Editor” menu item under the ** ”Preferences” menu in our custom menu module. val VARCHAR2(32000). Edit_Textitem(x. 10. ed_ok). width.20.
partly obscuring it. Horizontal Toolbar. containers typically used for modal dialogs that require immediate user interaction.Shik Mahamood Ali END. 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. property_true). Showing and hiding a canvas programmatically SHOW_VIEW('a_stack'). tab canvases are displayed on top of a content canvas. or SET_VIEW_PROPERTY('a_stack'. visible. A content canvas is the "base" view that occupies the entire content pane of the window in which it is displayed. and text items. There are four types of canvas objects: Content. such as check boxes. 3.Stacked Canvas A stacked canvas is displayed atop—or stacked on—the content canvas assigned to the current window. .Toolbar Canvas A toolbar canvas often is used to create toolbars for individual windows. while vertical toolbars are displayed along the far left edge of a window. just under its menu bar. Tab pages (that collectively comprise the tab canvas) each display a subset of the information displayed on the entire tab canvas. 2. including canvases. visible. You must define at least one content canvas for each window you create. Stacked canvases obscure some part of the underlying content canvas. Dialog Dialog Windows Dialog windows are free-floating. WINDOW A window is a container for all visual objects that make up a Form Builder application. you can create additional windows as needed by inserting them under the Windows node in the Object Navigator. property_false). and Vertical Toolbar.Content Canvas The most common canvas type is the content canvas (the default type). Horizontal toolbar canvases are displayed at the top of a window. 1. and often are shown and hidden programmatically. You can create two types of toolbar canvases: horizontal or vertical. HIDE_VIEW('a_stack'). A single form can include any number of windows. Stacked. or SET_VIEW_PROPERTY('a_stack'. 4. Like stacked canvases. You can display more than one stacked canvas in a window at the same time.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. While every new form automatically includes a default window named WINDOW1. and data retrieval is performed. CANVAS 32 This object represents a background entity on which you place interface items. radio groups.
or iconify a modal window.Modal Windows Modal windows are usually used as dialogs. end users cannot resize. When- There are three styles of alerts: Stop. and Note. Each style denotes a different level of message severity. On some platforms.Document windows always are displayed within the MDI application window frame. REPLACE_CONTENT_VIEW (window_name VARCHAR2. REPLACE_CONTENT_VIEW built-in Replaces the content canvas currently displayed in the indicated window with a different content canvas. 2.'history'). Hide on Exit property For a modeless window. ** Built-in: REPLACE_CONTENT_VIEW ** Example: Replace the 'salary' view with the 'history' ** view in the 'employee_status' window.Shik Mahamood Ali Window Modality 33 1. . view_name VARCHAR2). Modeless Windows You can display multiple modeless windows at the same time. Modal windows are often displayed with a platform-specific border unique to modal windows. . and have restricted functionality compared to modeless 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. Form Builder also provides support for an SDI root window on Microsoft Windows. determines whether Form Builder hides the window automatically when the end user navigates to an item in another window. */ BEGIN Replace_Content_View('employee_status'. All other windows in the application are either document windows or dialog windows. Multiple Document Interface MDI applications display a default parent window. When-Window-Deactivated . for example. 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. scroll. modal windows are "always-ontop" windows that cannot be layered behind modeless windows. and end users can navigate freely among them (provided your application logic allows it). called the application window. On some platforms. Message severity is represented visually by a unique icon that displays in the alert window. On most GUI platforms. Single Document Interface Although MDI is the default system of window management during Forms Runtime. you can layer modeless windows so that they appear either in front of or behind other windows. Caution. END. 2. Trigger . MDI and SDI windows 1. When-Window-Closed .
al_id Alert. BEGIN al_id := Find_Alert('My_Error_Alert'). Searches the list of valid alerts in Form Builder.property VARCHAR2. Define the variable with a type of Alert. value VARCHAR2).Shik Mahamood Ali 34 FIND_ALERT (alert_name VARCHAR2). the subprogram returns an alert ID. err_txt ).button NUMBER. When the given alert is located. Displays the given alert. You must return the ID to an appropriately typed variable. OBJECT GROUPS An object group is a container for a group of objects. END. ** Built-in: SET_ALERT_PROPERTY ** Example: Places the error message into a user-defined alert ** named 'My_Error_Alert' and displays the alert. You define an object group when you want to package related objects for copying or sub classing in another module. al_button Number. 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. and returns a numeric value when the operator selects one of three alert buttons. Set_Alert_Property(al_id. Changes the message text for an existing alert. You can use object groups to bundle numerous objects into higher-level building blocks that you can use again in another application. Changes the label on one of the buttons in an alert. VARCHAR2). SET_ALERT_BUTTON_PROPERTY(alert_id ALERT. alert_message_text. Using Object Groups • Blocks include: Items Item-level triggers Block-level triggers Relations • Object groups cannot include other object groups • Deleting: An object group does not affect the objects An object affects the object group Copying an Object . ** Trigger: On-Error */ DECLARE err_txt VARCHAR2(80) := Error_Text. Returns a BOOLEAN value that indicates whether the object ID is available. al_button := Show_Alert( al_id ). SET_ALERT_PROPERTY (alert_id ALERT. ID_NULL (Alert BOOLEAN). message SHOW_ALERT (alert_id Alert). property NUMBER. You define an object group when you want to package related objects so you can copy or subclass them in another module.
Shik Mahamood Ali 35 Copying an object creates a separate. and distribute standard and reusable objects. . by using Object Libraries. and program units. 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. • Changes made to a copied object in the source module do not affect the copied object in the target module. An object library can contain simple objects. but they are protected against change in the library. Objects can be used as standards (classes) for other objects. such as buttons and items. store. maintain. property classes. Object libraries simplify the sharing of reusable components. and personal standards Simplifies the sharing of reusable components Object libraries are convenient containers of objects for reuse. object groups. unique version of that object in the target module. You can use the Object Library to create. 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 A SmartClass is a special member of an Object Library. Use copying to export the definition of an object to another module. and personal standards. Any objects owned by the copied object are also copied. Reusing components enables you to: • Apply standards to simple objects. it can be used to subclass existing objects in a form using the SmartClass option from the right mouse button popup menu. In addition. you can rapidly create applications by dragging and dropping predefined objects to your form. project. Object Library members which are not SmartClasses can only be used to create new objects in form modules into which they are added. project. • • • • Is a convenient container of objects for reuse Simplifies reuse in complex environments Supports corporate. They simplify reuse in complex environments. Unlike other Object Library members. and they support corporate.
You can mark many different objects that are spread across multiple object libraries as SmartClasses. you can mark them as SmartClasses by selecting each object in the object library and choosing Object—>SmartClass. functions. Reasons to share objects and code: Ø Increased productivity Ø Increased modularity Ø Decreased maintenance Ø Maintaining standards . and packages.PLX PL/SQL Library Module Binary PL/SQL Library Module Text PL/SQL Library Module Executable . and alerts. A single library can contain many program units that can be shared among the Oracle Developer modules and applications that need to use them. 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. or graphic modules Ø Supports dynamic loading of program units FUNCTION locate_emp(bind_value IN NUMBER) RETURN VARCHAR2 IS v_ename VARCHAR2(15).PLL . RETURN(v_ename).Shik Mahamood Ali 36 If you frequently use certain objects as standards. report.menu. including procedures. END.MMT Menu Module Text .PLD . • 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. date items. such as standard buttons.MMB Menu Module Binary .MMX Menu Module Executable Form Builder Built-in Package EXEC_SQL Provides built-ins for executing dynamic SQL within PL/SQL procedures . BEGIN SELECT ename INTO v_ename FROM emp WHERE empno = bind_value.
Shik Mahamood Ali 37 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.
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.
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. The following settings are valid for this property: 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.
Shik Mahamood Ali 38 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
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 ü Interface event triggers o When-Button-Pressed o When-Checkbox-Changed o When-Image-Activated o When-Image-Pressed o When-Radio-Changed
Shik Mahamood Ali o o o o o o o o o o o ü When-Timer-Expired When –List-Changed When –List-Activated When –Tree-Note-Activated When –Tree-Note-Expanded When –Tree-Note-Selected Key- [all] When-Window-Activated When-Window-Closed When-Window-Deactivated When-Window-Resized
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
Query-time triggers o o Pre-Query Post-Query
ü Transactional triggers. o o o o o o o o On-Count On-Delete. On-Insert. On-Lock. On-Logon. On-Logout. On-Select. On-Update.
Shik Mahamood Ali o Post-Database-Commit. o Post-Delete. o Post-Forms-Commit. o Post-Insert. o Post – Select. o Post-Update. o o o o o Pre-Commit. Pre-Delete. Pre-Insert. Pre-Select. Pre-Update.
ü 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.
Fires when Form Builder creates a new record. For example, when the operator presses the [Insert] key, or navigates to the last record in a set while scrolling down, Form Builder fires this trigger.
• Perform an action whenever Form Builder attempts to create a new record in a block. For example, to set complex, calculated, or data-driven default values that must be specified at runtime, rather than design time.
BEGIN /* ** Default Invoice Due Date based on Customer's ** Net Days Allowed value from the Customer block. the value of SYSTEM.RECORD_STATUS is unreliable because there is no current record. • Fires In • • • CLEAR_BLOCK COUNT_QUERY ENTER_QUERY Clear_Block(No_Validate). CLOSE ship_dflt. */ OPEN ship_dflt. When-Database-Record Fires when Form Builder first marks a record as an insert or an update. An alternative is to use GET_RECORD_PROPERTY to obtain the record status. /* ** Default the shipping method based on this customers ** preference. FETCH ship_dflt INTO :Invoice. The When-Clear-Block trigger does not fire when Form Builder clears the current block during the CLEAR_FORM event. When-Remove-Record Fires whenever the operator or the application clears or deletes a record. to adjust a running total that is being calculated for all of the records displayed in a block. its value is always accurate. Perform an action whenever a record is cleared or deleted. Used For • Perform an action whenever Form Builder changes a record's status to Insert or Update. Because GET_RECORD_PROPERTY requires reference to a specific record.INTO. */ :Invoice. • 4. We could ** use SELECT. 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. For example. . When-Clear-Block Perform an action whenever Form Builder flushes the current block. In a When-Clear-Block trigger. 3. that is. you might want to perform an automatic commit whenever this condition occurs. DECLARE CURSOR ship_dflt IS SELECT val FROM cust_pref WHERE Custid = :Customer.Shik Mahamood Ali WHEN-CREATE-RECORD TRIGGER 41 This example assigns data-driven or calculated default values without marking the record as changed. For example.. stored in a preference table.. Used For • Use a When-Clear-Block trigger to perform an action every time Form Builder flushes the current block. 2. removes all records from the block. END. and after the operator attempts to navigate out of the item. 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. but explicit cursor is more ** efficient.Ship_Method.Net_Days_Allowed.Due_Date := SYSDATE + :Customer.Custid AND pref = 'SHIP'. This generally occurs only when the operator modifies the first item in a record.
Initiate an action when the operator toggles the state of a check box. When-Checkbox-Changed Trigger examples This trigger on the :S_ord.Shik Mahamood Ali Fires In • • CLEAR_RECORD DELETE_RECORD 42 B. or for other item. such as When-Button-Pressed. or form level functionality. 2. Some of these trigger. then the Date_Shipped item is enabled. END IF.. END. fire only in response to operator input or manipulation. the internal value of that item does not change until navigation is completed successfully.. . 1. This example executes a COMMIT_FORM if there are changes in the form. either with the mouse or through keyboard selection Usage Notes • • Use a When-Checkbox-Changed trigger to initiate a task dependent upon the state of a check box. Usage Notes • Use a When-Button-Pressed trigger to perform navigation. to calculate text item values. When an operator clicks in a check box. Thus. like When-Window-Activated. or using the keyboard. /* If the Form_Status is not back to 'QUERY' ** following a commit. RAISE Form_Trigger_Failure. block.order_filled item prevents the date_shipped item from being updated if the user marks the order as filled ( checked on ). When-Checkbox-Changed Fires when an operator changes the state of a check box. Others.Form_Status = 'CHANGED' THEN Commit_Form.INTERFACE EVENT TRIGGERS Interface event triggers fire in response to events that occur in the form interface. END IF.'). BEGIN IF :System. the value of the check box item remains as it was before the operator navigated to it. by clicking with a mouse. So for all navigation triggers that fire before the When-Checkbox-Changed trigger. */ IF :System. then the commit was not successful. either by clicking with the mouse.Form_Status <> 'QUERY' THEN Message('Unable to commit order to database. can fire in response to both operator input and programmatic control. the When-Checkbox-Changed trigger is the first trigger to register the changed value of a check box item. or using the keyboard. When-Button-Pressed Fires when an operator selects a button.If the check box is set off.
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. not for dropdown lists or combo box style list items.property_true). Fires when an operator uses the mouse to: • Single-click on an image item. End. 5. When-Image-Pressed Initiate an action whenever an operator clicks on an image item. Usage Notes • Use a When-Image-Pressed trigger to perform an action when an operator clicks or double clicks on an image item. Else Set_Item_Property(‘s_ord.filled’) then Set_Item_Property(‘s_ord.Shik Mahamood Ali 43 Begin If checkbox_checked(‘s_ord. Usage Notes • A When-List-Activated trigger fires only for T-list style list items. When-List-Changed Trigger Description .JPG’. End if. Begin READ_IMAGE_FILE(‘ST_’||TO_CHAR(:STMAST.property_false). When-List-Activated Trigger Fires when an operator double-clicks on an element in a list item that is displayed as a T-list. 6. 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.date_shipped’. The display style of a list item is determined by the List Style property.Update_allowed’.date_shipped’. § Note : That When-Image-Pressed also fires on a double-click.Update_allowed’. End. Double-click on an image item. 4. 3.’STMAST:STIMAGE’).STID)||’. When-Image-Activated Initiate an action whenever the operator double-clicks an image item.’JPG’.
if a When-List-Changed trigger is attached to a combo box style list item.payment_type:=’CASH’. 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. or using the keyboard. or de-selects the currently selected radio button. If not. (De-selecting a radio button in a radio group sets the radio group value to NULL. End if. End. Initiate an action when an operator changes the current radio button selected in a radio group item.’EXCELLENT’) then :s_ord.payment_type=’CREDIT’ then Select credit_rate into v_credit from customer where custid=:s_ord. Exception When no_data_found then Message(‘Invalid Student ‘). Usage Notes • Use a When-Radio-Changed trigger to perform an action depending on the state of a radio group. message(‘Warning – Customer must pay cash‘). it fires each time the end user enters or modifies entered text. End if.Shik Mahamood Ali 44 Fires when an end user selects a different element in a list item or de-selects the currently selected element. In addition. then the payment type is set to cash. 8. Thus. When-Timer-Expired . the internal value of that item does not change until navigation is completed successfully. or if the end user causes a procedure to be invoked which changes the value. the When-List. 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. End. For example. Begin If :s_ord. either by clicking with the mouse.credit_rate%type. Begin Select stname into :stname from the stmast where stid=:stid. the value of the radio group remains as it was before the operator navigated to it. 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. operators use this technique in Enter Query mode to exclude a radio group from a query. Declare v_credit customer. this trigger immediately confirms whether the customer has a good or excellent credit rating.custid. the When-Radio-Changed trigger is the first trigger to register the changed value of a radio group. Populate student name based on the selected student id.Changed trigger will not fire if an end user duplicates the item using a key mapped to the DUPLICATE_ITEM built-in. • When-Radio-Changed Trigger examples When the user selects credit as the payment type for an order. If v_credit NOT_IN(‘GOOD’. 7.) When an operator clicks an item in a radio group.
msg_1 VARCHAR2(80) := 'Wrap up the first phase of your presentation'. DECLARE timer_id TIMER. Fires In • Process Expired Timer When-Timer-Expired Trigger examples Example The following example displays a message box each time a repeating timer expires. Usage Notes Timers are created programmatically by calling the CREATE_TIMER built-in procedure.timer_count = 1 THEN Set_Alert_Property(alert_id.timer_count := 1 BEGIN timer_id := FIND_TIMER('tele_timer'). BEGIN :GLOBAL. or perform any task that should occur after a specified interval. call_status NUMBER. The message box is displayed each time a repeating timer expires. • • • The When-Timer-Expired trigger can not fire during trigger. Use a When-Timer-Expired trigger to initiate an event. alert_id ALERT. END IF.' two_minutes NUMBER(6) := (120 * 1000). NO_CHANGE). Next_Record. ALERT_MESSAGE_TEXT. The following example is from a telemarketing application. navigation. alert_id := FIND_ALERT('tele_alert').Shik Mahamood Ali Description 45 Fires when a timer expires. and message boxes are displayed to prompt the salesperson through each stage of the call. two_minutes. msg_3 VARCHAR2(80) := 'Ask for the order or repeat the close.timer_count := 0. IF :GLOBAL. . Initiate an action when a programmatic timer expires. ELSIF call_status = ALERT_BUTTON2 THEN :GLOBAL. one_and_half NUMBER(5) := (90 * 1000). update item values. call_status := Show_Alert(alert_id). IF call_status = ALERT_BUTTON1 THEN Delete_Timer(timer_id).'. ELSE Set_Timer(timer_id. You can call GET_APPLICATION_PROPERTY(TIMER_NAME) in a When-Timer-Expired trigger to determine the name of the most recently expired timer. in which sales calls are timed. msg_2 VARCHAR2(80) := 'Move into your close. or transaction processing. msg_1).
. but window activation can also occur independently of navigation. END. call_status := Show_Alert(alert_id).timer_count = 2.Shik Mahamood Ali 46 ELSIF :GLOBAL. • Enforce navigation to a particular item whenever a window is activated.EVENT_WINDOW to a variable or global variable. END IF. say. Next_Record. NO_CHANGE. one_and_half. ELSE Set_Timer(timer_id. ELSIF call_status = ALERT_BUTTON2 THEN :GLOBAL. • Keep track of the most recently fired window trigger by assigning the value from SYSTEM. This occurs at form startup and whenever a different window is given focus. ELSE Set_Timer(timer_id. IF call_status = ALERT_BUTTON1 THEN Delete_Timer(timer_id). Example: Begin GET_WINDOW_PROPERTY( window_name. property).timer_count := 0. :GLOBAL. NO_CHANGE).timer_count := 0. End. 9. navigating to an item in a different window always activates that window. msg_2). Thus. Note that on some window managers. This operation is independent of navigation to an item in the window. When-Window-Activated Initiate an action whenever an operator or the application activates a window. msg_3). ELSIF call_status = ALERT_BUTTON2 THEN :GLOBAL. NO_REPEAT). END IF. call_status := Show_Alert(alert_id). a window can be activated by. END IF. Usage Notes: Use this trigger to perform the following types of tasks: • Capture initial settings of window properties. by way of the GET_WINDOW_PROPERTY built–in. Next_Record. IF call_status = ALERT_BUTTON1 THEN Delete_Timer(timer_id).timer_count = 2 THEN Change_Alert_Message(alert_id. clicking on its title bar. Fires when a window is made the active window. ELSE Change_Alert_Message(alert_id.
w NUMBER.) This trigger also fires at form startup. . Usage Notes: Use this trigger to perform any one of the following types of tasks: • • • • Capture the changed window properties. SET_WINDOW_PROPERTY. such as width. (Even if the window is not currently displayed.When-Window-Closed Initiate an action whenever an operator closes a window with the window manager's Close command. • You can close a window with the HIDE_WINDOW . resizing the window programmatically fires the When–Window–Resized trigger. Fires when a window is resized. Fires when an operator deactivates a window by setting the input focus to another window. Example: /* ** Built–in: RESIZE_WINDOW ** Example: Set Window2 to be the same size as Window1 */ PROCEDURE Make_Same_Size_Win( Window1 VARCHAR2. 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’. x coordinate. Usage Notes: • Use this trigger to programmatically close a window when the operator issues the window–manager Close command. h NUMBER. Audit the actions of an operator. and EXIT_FORM built–in subprograms. Window2 VARCHAR2) IS wn_id1 Window. It does not fire when a window is iconified. When-Window-Resized Initiate an action whenever a window is resized. 11.Shik Mahamood Ali 47 10 . When-Window-Deactivated Initiate an action whenever a window is deactivated as a result of another window becoming the active window. 12. Maintain certain visual standards by resetting window size if the window was improperly resized. or y coordinate. height. either by the operator or programmatically through a call to RESIZE_WINDOW or SET_WINDOW_PROPERTY. PROPERTY_OFF). either by the operator or programmatically. • You can hide the window that contains the current item. VISIBLE. 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. when the root window is first drawn. Set input focus in an item on the target window.
Lock command on the default menu 1. Before you can attach key triggers to these keys. you can define a Key-EXIT trigger to replace the default functionality of the [Help] key. For example. You can attach Key–Fn triggers to 10 keys or key sequences that normally do not perform any Oracle Forms operations. h := Get_Window_Property(wn_id1.WIDTH). END.[ALL] ( KEY TRIGGERS ) Key Triggers have a one-to-one relationship with specific keys.e. i. w. you or the DBA must use Oracle Terminal to map the keys to the appropriate functions. h ). . Usage Notes: Use Key–Fn triggers to create additional function keys for custom functions. These keys are referred to as Key–F0 through Key–F9.HEIGHT). C. */ wn_id1 := Find_Window(Window1). the trigger fires when operator presses a specific key or key-sequence. Replace the default function associated with a function key.Shik Mahamood Ali BEGIN 48 /* ** Find Window1 and get it’s width and height. 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 Key–UP Key–UPDREC 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] [Up] Equivalent to Record.Key–Fn Trigger A Key–Fn trigger fires when an operator presses the associated key. KEY. w := Get_Window_Property(wn_id1. /* ** Resize Window2 to the same size */ Resize_Window( Window2.
When this occurs.total THEN Message(’PO Distributions do not reconcile. • Perform one specific action whenever an operator presses any key. The default master/detail triggers enforce coordination between records in a detail block and the master record in a master block. ALERT_MESSAGE_TEXT. KEY-DELREC TRIGGER ON S_CUSTOMER BLOCK DELETE_RECORD. 1. 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. however. Oracle Forms still displays the function key’s default entry in the Show Keys screen. END.number. On-Clear-Details . IF SHOW_ALERT (’question_alert’) = ALERT_BUTTON1 THEN EXIT_FORM. BEGIN SELECT SUM(dollar_amt) INTO the_sum FROM po_distribution WHERE po_number = :purchase_order. ’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. END IF. DECLARE the_sum NUMBER. use Key–Others triggers to perform the following tasks: • Disable all keys that are not relevant in a particular situation. KEY-EXIT AT FORM LEVEL SET_ALERT_PROPERTY (’question_alert’. END IF. END. Usage Notes: Use Key–Others triggers to limit an operator’s possible actions. Specifically.Shik Mahamood Ali 49 2. IF the_sum <> :purchase_order.’). KEY-COMMIT TRIGGER AT FORM LEVEL: EMPLOYEES FORM BEGIN IF GET_APPLICATION_PROPERTY( CALLING_FORM ) IS NULL THEN COMMIT_FORM. D. 2. ELSE POST. END IF. Key–Others Trigger A Key–Others trigger fires when an operator presses the associated key. 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). RAISE Form_Trigger_Failure. A Key–Others trigger overrides the default behavior of a Runform function key (unless one of the following restrictions apply).
DBMS_ERROR_TEXT. Trapping certain errors at the block or item level can be difficult if these errors occur while Oracle Forms is performing internal navigation. • Example: The following example checks specific error message codes and responds appropriately. lv_errtyp VARCHAR2(3) := ERROR_TYPE. • When Deferred coordination is set and this trigger fires. Message handling triggers fire in response to these default messaging events. • When Immediate coordination is set. E. 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. In most cases. 1. 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. you can call the SET_BLOCK_PROPERTY(COORDINATION_STATUS) built–in.MESSAGE-HANDLING TRIGGERS Form Builder automatically issues appropriate error and informational messages in response to runtime events. On-Error Replace a default error message with a custom error message. rather than to a block or item. such as during a Commit process. 3. this causes the details of the instantiated master to be populated immediately. • If you intend to manage block coordination yourself. Immediate coordination is the default. Usage Notes: Oracle Forms creates the On–Clear–Details trigger automatically when you define a master– detail block relation.Shik Mahamood Ali 50 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. BEGIN IF (lv_errcod = 40nnn) THEN /* ** Perform some tasks here */ ELSIF (lv_errcod = 40mmm) THEN . or DBMS_ERROR_CODE built–in function in an On–Error trigger to identify a specific error condition. Oracle Forms marks the blocks as needing to be coordinated. lv_errtxt VARCHAR2(80) := ERROR_TEXT. 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. DECLARE lv_errcod NUMBER := ERROR_CODE. ERROR_TEXT. or to trap and recover from an error. On–Error triggers should be attached to the form. ERROR_TYPE.
F.. lv_errtype VARCHAR2(3) := MESSAGE_TYPE. ELSIF (lv_errcod = 40zzz) THEN ** More tasks here */ ELSE Message(lv_errtyp||’–’||to_char(lv_errcod)||’: ’||lv_errtxt).. for example.QUERY-TIME TRIGGERS Query-time triggers fire just before and just after the operator or the application executes a query in a block. This prevents attempts at very large queries. END. lv_errcod NUMBER := MESSAGE_CODE. BEGIN IF lv_errcod = 40350 THEN alert_button := Show_Alert(’continue_alert’).. just before sending the SELECT statement to the database. Pre-Query Validate the current query criteria or provide additional query criteria programmatically. ELSE Message(lv_errtyp||’–’||to_char(lv_errcod)||’: ’||lv_errtxt). END IF. 1. This Pre-Query trigger on the S_ORD block only permits queries if there is a restriction on either the Order ID.. END IF. IF alert_button = ALERT_BUTTON1 THEN . END. 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. or Date Shipped. Date Ordered. On-Message To trap and respond to a message. END IF. 2. ELSE . lv_errtxt VARCHAR2(80) := MESSAGE_TEXT. . to replace a default message issued by Form Builder with a custom message...Shik Mahamood Ali /* ** More tasks here */ 51 . RAISE Form_Trigger_Failure.
Payplan_Id.name:=’%’||:S_customer. Use it to check or modify query conditions.’). ** Use Explicit Cursor for highest efficiency. and displays this number as a summary value in the non base table item :Lineitem_count. DECLARE CURSOR lookup_payplan IS SELECT Payplan_Desc FROM Payplan WHERE Payplan_Id = :Employee. CURSOR lookup_area IS SELECT Area_Name FROM Zip_Code WHERE Zip = :Employee. RAISE Form_Trigger_Failure. 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.*/ OPEN lookup_payplan. .Shik Mahamood Ali • • • 52 To test the operator’s query conditions. BEGIN /* Lookup the Payment Plan Description given the Payplan_Id in the Employee Record just fetched.’Y’)=’N’ then :S_Customer. END IF.Ename IS NULL AND :Employee. Make sure the user has given one of the two Columns which we have indexed in their search criteria. Post-Query Perform an action after fetching a record.lineitem_count FROM S_ITEM WHERE ord_id = :S_ORD. Post-Query fires for each record that is fetched into the block as a result of a query. 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).name || ‘%’. Example: This example retrieves descriptions for code fields. 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. [ exact_match – Check Box User can specify if or not a query condition for a customer name should exactly match the table value. End. Use it to perform calculations and populate additional items. ] IF nvl(:control. B] This Post-Query trigger on the S_ORD block selects the total count of line items for the current Order.Mgr IS NULL THEN Message(’Supply Employee Name and/or Manager Id ’||’for Query. This trigger is defined at block level or above. otherwise fail the query with a helpful message A] IF :Employee. such as looking up values in other tables based on a value in the current record. [ Set the initial value property to “Y”. END IF. 2. Fires once for each record fetched into the block. for display in non–database items in the current block.exact_match. FETCH lookup_payplan INTO :Employee.Payplan_Desc_Nondb.id. Begin SELECT COUNT(ord_id) INTO :S_ORD.Zip.
navigation triggers do not fire if they belong to a unit that is smaller than the current validation unit. POST-QUERY fires 10 times. FETCH lookup_area INTO :Employee.navigation triggers fire during navigation. When Do Pre. Pre.and Post.and Post-Navigation Triggers Fire? The Pre. CLOSE lookup_area.NAVIGATIONAL TRIGGERS Navigational triggers fire in response to navigational events. Example The Pre-Text-Item trigger fires just before entering a text item. 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. Use it to perform calculations and populate additional items. END. navigational events occur as Form Builder moves the input focus from the current item to the target item. When Do Navigation Triggers Not Fire? The Pre. */ OPEN lookup_area. For instance. Use Explicit ** Cursor for highest efficiency.Shik Mahamood Ali CLOSE lookup_payplan. 53 /* ** Lookup Area Descript given the Zipcode in ** the Employee Record just fetched. when the operator clicks on a text item in another block.and Post-Text-Item triggers do not fire.TRIGGERS Fire as Form Builder navigates internally through different levels of the object hierarchy. that is just before entry to or just after exit from the object specified as part of the trigger name. A Post-Query trigger fires as each record is fetched (except array processing). • • A Pre-Query trigger fires before a query executes. 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.AND POST. but before the statement is actually issued. For instance. Pre-query trigger fires before pre-select trigger. I ] PRE. if the validation unit is Record. A query fetched 10 records How many times does a PRE-QUERY Trigger and POST-QUERY Trigger will get executed? PRE-QUERY fires once.and Post. What Happens When a Navigation Trigger Fails? . G.Area_Desc_Nondb. Use it to check or modify query conditions.
RAISE form_trigger_failure. Fires during the Enter the Block process. END IF.or Post navigation trigger fails. Pre-Form Perform an action just before Form Builder navigates to the form from "outside" the form. 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: . it appears that the input focus has not moved at all. during navigation from one block to another.IS_ROLE_ENABLED(’TECHNICAL’) THEN MESSAGE(’You are not authorized to run this application’). the input focus returns to its initial location (where it was prior to the trigger firing). 1.Shik Mahamood Ali 54 If a Pre. To the user. such as at form startup. 2.IS_ROLE_ENABLED(’ADMINISTRATIVE’) or (DBMS_SESSION. IF not (DBMS_SESSION. PAUSE. Pre-Block Perform an action before Form Builder navigates to the block level from the form level.
such as when exiting the form. property_false). Use a Pre–Record trigger to keep a running total. Post-Form Perform an action before Form Builder navigates to "outside" the form. during navigation to a different record. To display a message to the operator upon form exit. Usage Notes: Use a Pre–Text–Item trigger to perform the following types of tasks: • • Derive a complex default value. if validation fails in the form. IF (( dynamic–condition) AND :System. when a form is exited. Record the current value of the text item for future reference. Usage Notes: You can use a Post–Form trigger for the following tasks: • • To clean up the form before exiting. enabled. 4. 3.stock_button’. The following trigger prevents the user from entering a new record given some dynamic condition and the status of SYSTEM. Usage Notes: • • Fires during the Enter the Record process. End. Pre-Text-Item Perform an action before Form Builder navigates to a text item from the record level. 6.Shik Mahamood Ali begin 55 SET_ITEM_PROPERTY(’CONTROL. For example. for example. and store that value in a global variable or form parameter. use a Post–Form trigger to erase any global variables that the form no longer requires. Usage Notes: . This trigger does not fire when the form is exited abnormally. based on other items previously entered into the same record. END IF. Fires during the Leave the Form process.Record_Status = ’NEW’) THEN RAISE Form_Trigger_Failure. Post-Block Manipulate the current record when Form Builder leaves a block and navigates to the form level. 5. Pre-Record Perform an action before Form Builder navigates to the record level from the block level.RECORD_STATUS evaluating to NEW.
this trigger fires when the input focus moves from a text item to any other item. Example Set_item_property (‘control. NEXT_RECORD. lst_itm VARCHAR2(80). the record that had input focus when the Leave the Block event occurred.’||Get_Block_Property(cur_blk. you can do so from within this trigger. II] WHEN-NEW-INSTANCE-TRIGGERS . 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.Shik Mahamood Ali • • 56 Use a Post–Block trigger to validate the block’s current record. BEGIN lst_itm := cur_blk||’. if you want to set a visual attribute for an item as the operator scrolls down through a set of records. You might also use this trigger to test a condition and prevent the user from leaving a block based on that condition. The Leave the Record process can occur as a result of numerous operations. 8. Fires during the Leave the Record process. ELSE Next_Item. END. the Post–Record trigger fires whenever the operator or the application moves the input focus from one record to another. CREATE_RECORD. Post-Record Manipulate a record when Form Builder leaves a record and navigates to the block level. END IF.cmdsave’. Post-Text-Item Manipulate an item when Form Builder leaves a text item and navigates to the record level. Example: /* ** Built–in: NEXT_RECORD ** Example: If the current item is the last item in the ** block. IF cur_itm = lst_itm THEN Next_Record. Specifically. For example. NEXT_BLOCK. enabled. DELETE_RECORD. including INSERT_RECORD. Fires during the Leave the Item process for a text item. 7. cur_blk VARCHAR2(80) := :System. that is.LAST_ITEM). Specifically.Cursor_Item. PREVIOUS_BLOCK. property_false).Cursor_Block. etc. 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.
width_win_inventory := GET_WINDOW_PROPERTY(’win_inventory’. by including the following code in your When-New-Form-Instance trigger: 1a. when the form returns to a quiet state to wait for operator input. Perform a query of all orders.“object”-Instance Triggers Fire? The When-New-”object”-Instance triggers fire immediately after navigation to the object specified as part of the trigger name.Shik Mahamood Ali 57 Fire at the end of a navigational sequence that places the input focus on a different item. WIDTH).height_win_order := GET_WINDOW_PROPERTY(’win_order’. 1. When-New-Form-Instance Trigger at Form Level BEGIN SET_WINDOW_PROPERTY( forms_mdi_window. :GLOBAL. 1b.height_win_inventory := GET_WINDOW_PROPERTY(’win_inventory’. When Do When-New.where_cls’). TITLE. ’Summit Sporting Goods Application’). EXECUTE_QUERY. (Occurs after the Pre-Form trigger fires). MAXIMIZE ). when the ORDERS form is run. END. a record group is created and the hierarchical tree is populated.HEIGHT). SET_BLOCK_PROPERTY(’prod_lov_blk’. END.:GLOBAL. BEGIN DEFAULT_VALUE(’’. 1d. ’'GLOBAL. DEFAULT_WHERE. :GLOBAL. When-New-Form-Instance Perform an action at form start-up. The example locates the hierarchical tree first. DECLARE htree ITEM. Example The When-New-Item-Instance trigger fires immediately after navigation to a new instance of an item.width_win_order := GET_WINDOW_PROPERTY(’win_order’.HEIGHT).WIDTH). BEGIN EXECUTE_QUERY. 1c. Specifically.where_cls). v_ignore NUMBER. :GLOBAL. EXECUTE_QUERY. these triggers fire just after Form Builder moves the input focus to a different item. Example This code could be used in a WHEN-NEW-FORM-INSTANCE trigger to initially populate the hierarchical tree with data. :GLOBAL. Then. SET_WINDOW_PROPERTY( forms_mdi_window. WINDOW_STATE. END. rg_emps RECORDGROUP. .
Example The following example of a When-New-Block-Instance trigger conditionally sets the DELETE ALLOWED property to FALSE. Ftree. 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. fires after the When-New-Block-Instance trigger.Shik Mahamood Ali 58 BEGIN htree := Find_Item('tree_block. IF GET_APPLICATION_PROPERTY(username) = ’SCOTT’ THEN SET_BLOCK_PROPERTY(’S_ITEM’. Begin Filename:=get_product_image(:S_ITEM. For example. if one exists 1] Declare Filename varchar2(20). rg_emps). End if End.*/ BEGIN IF :Emp. rg_emps := Create_Group_From_Query('rg_emps'. PROPERTY_FALSE). When-New-Record-Instance Perform an action immediately after the input focus moves to an item in a different record. 2] 1.Set_Tree_Property(htree. Usage Notes: Use a When–New–Record–Instance trigger to perform an action every time Oracle Forms instantiates a new record. and populates the product_image item with a picture of the products. END. when an operator presses [Down] to scroll through a set of records. to_char(empno) ’ ||' from emp ' ||'connect by prior empno = mgr ' ||’start with job = ’’PRESIDENT’’’).Job = ’CLERK’ THEN Break. END IF.’select 1. v_ignore := Populate_Group(rg_emps).a Example: Brings up the debugging window for a particular ** value of the ’JOB’ item anytime the user changes records. level. . NULL.PRODUCT_ID).’tiff’. Usage Notes: Use a When–New–Block–Instance trigger to perform an action every time Oracle Forms instantiates a new block.’S_ITEM. 3.DELETE_ALLOWED. each time Oracle Forms instantiates a new record in the block. Ftree.htree3'). but before the When-New-Item-Instance trigger. Example The Cursor arrives in each record of the S_Item block. If Filename= ‘ No file’ then Null. 2. If the new record is in a different block. ename.product_image’). in other words. Else Read_Image_File(filename.RECORD_GROUP. Oracle Forms fires this trigger each time the input focus moves to the next record.
END IF. 3].cancel_query = 'Y' and :system. :global.Shik Mahamood Ali Call_Form(’clerk_timesheet’). If the new item is in a different block. 4.Empno.] BEGIN IF (:global. Perform an action immediately after the input focus moves to a different item. .Example: Clear the current item if it does not represent ** the first day of a month.Hiredate.Cursor_Item = ’EMP.date_shipped’).mode = 'ENTER-QUERY') THEN Exit_Form. END.EMPNO’ and :System. Clear_Block(No_Validate). BEGIN IF :System. property_true). 59 3. 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.date_shipped’.order_filled’)THEN SET_ITEM_PROPERTY(’S_ORD.Employee_Id := :Emp. END IF. Usage Notes Use a When-New-Item-Instance trigger to perform an action whenever an item gets input focus. END IF.Empno IS NOT NULL THEN :Global.UPDATE_ALLOWED. 1] IF CHECKBOX_CHECKED(’S_ORD. The WhenNew-Item-Instance trigger is especially useful for calling restricted (navigational) built-ins. END IF.Mode = ’ENTER–QUERY’ THEN IF NOT Show_Lov(’my_lov’) THEN RAISE Form_Trigger_Failure. Message(’This date must be of the form 01–MON–YY’). BEGIN IF TO_CHAR(:Emp. END.cancel_query = 'N'.When-New-Item-Instance Fires when the input focus moves to an item. 4]. it fires after navigation to an item. END. fires after the When-New-Block-Instance trigger. GO_ITEM(’S_ORD. 2] Built–in: CLEAR_ITEM . when Form Builder is ready to accept input in an item that is different than the item that previously had input focus. END IF. Break. END IF. The following trigger accomplishes that operation.’DD’) <> ’01’ THEN Clear_Item. END. End if. Specifically. BEGIN IF :Emp.
At validation time. The default validation unit is item. When Does Validation Occur? Form Builder carries out validation for the validation unit under the following conditions: • 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). The following events then occur. This includes when changes are committed. Validation occurs at: • Item level: Form Builder records a status for each item to determine whether it is currently valid. then Form Builder first performs standard validation checks to ensure that the value conforms to the item’s properties. block. H. and form levels. These checks are carried out before firing any When-Validate-Item triggers that you have defined. all records below that level are validated. then control is passed back to the appropriate level. programmatic control. or form by the designer. If validation fails.Range (Lowest-Highest Allowed Value) . • The operator or a trigger navigates out of the validation unit. so that the operator can make corrections. and a When-Validate-Record trigger is then fired.Required (if so. then the status of each item in the record is checked. it is set to valid. validation succeeds.Validate from List (see later in this lesson) • Record level: After leaving a record. Standard checks include the following: . and processing continues normally. if you commit (save) changes in the form. VALIDATION TRIGGERS 60 Validation triggers fire when Form Builder validates data in an item or record. the LOV is not displayed. . such as a Commit operation. depending on the circumstances: • If the value in the text item matches one of the values in the first column of the LOV. When the record passes these checks. Validation occurs at item. If not. Do this by setting the Validate from List property to Yes for the item. you can optionally use the LOV contents to validate data entered in the item. but can also be set to record. Form Builder then automatically uses the item value as a non case-sensitive search string on the LOV contents.Data type . if present. unless you have suppressed this action. then is the item null?) . then all records in the form are validated. If an item has been changed and is not yet marked as valid. • 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.Shik Mahamood Ali END.Format mask . • Block and form level: At block or form level. block. Form Builder performs validation checks during navigation that occurs in response to operator input. or default processing. For example. Form Builder checks to see whether the record is valid. Using LOVs for Validation When you attach an LOV to a text item by setting the LOV property of the item. record. The validation unit is discussed in the next section.
Shik Mahamood Ali 61 • If the item’s value causes a single record to be found in the LOV. When – Validate -Record . then the full LOV contents are displayed to the operator. The Defer_Required_Enforcement property postpones enforcement of the Required property from item validation to record validation. by default Form Builder will not allow navigation out of the item until a valid value is entered. Duplicate entries in COMMPLAN table!'). Specifically. Form Builder marks the changed item as Valid and does not re-validate it. When – Validate -Item Fires during the Validate the Item process. Form Builder displays the LOV and uses the text item value as the search criteria to automatically reduce the list. 2. • If the item value causes multiple records to be found in the LOV. EXCEPTION WHEN No. then the full LOV column value is returned to the item (providing that the item is defined as the return item in the LOV). Validation Triggers • Item level When-Validate-Item • Block level When-Validate-Record 1.Commcode. BEGIN SELECT description INTO :Employee. WHEN Too_Many_Rows THEN Message('Error.. Example The SELECT.Data_Found THEN Message('Invalid Commission Plan.Commplan_Desc FROM commplan WHERE commcode = :Employee. Use <List> for help'). Usage Notes • • Use a When-Validate-Item trigger to supplement Form Builder default item validation processing. it fires as the last part of item validation for items with the New or Changed validation status. and input focus is returned to the item if the trigger fails. Setting the Defer_Required_Enforcement property to Yes allows the operator to move freely among the items in the record. If validation succeeds. While this behavior is necessary to avoid validation loops. RAISE Form_Trigger_Failure. so that the operator must choose.INTO statement must return an error if more than one row is retrieved that matches the criteria. • If no match is found. RAISE Form_Trigger_Failure. • When-Validate-Item Trigger You have already used this trigger to add item-level validation. When an item has the Required property set to Yes. it does make it possible for your application to commit an invalid value to the database. The trigger fires after standard item validation. 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 is possible to write a When-Validate-Item trigger that changes the value of an item that Form Builder is validating.. but is a partial value of the LOV value. The item then passes this validation phase. END.
you can use this trigger to perform additional checks that may involve more than one of the record’s items. If validation succeeds. While this behavior is necessary to avoid validation loops. Form Builder marks the record and all of the fields as Valid and does not re-validate. This code presumes both date items are mandatory and that neither will be NULL. 3 Fire the Pre-Commit trigger. in the order they were entered. When-Validate-Record Trigger This trigger fires after standard record-level validation.End_Date THEN Message('Your date range ends before it starts!'). it does make it possible for your application to commit an invalid value to the database. 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. RAISE Form_Trigger_Failure. /* Method 1: Hardcode the item names into the trigger. . When-Validate-Record must be defined at block level or above. For all inserted or updated records of the block in sequential order: . I.Start_Date > :Experiment.Delete the row from the base table or fire the On-Delete trigger.Fire the Post-Delete trigger. 2 Process save point. Since these two text items have values that are related.Fire the Pre-Delete trigger. END. Because Form Builder has already checked that required items for the record are valid. Use a When-Validate-Record trigger to supplement Form Builder default record validation processing. For all deleted records of the block (in reverse order of deletion): . when the operator has left a new or changed record. . rather than check each item separately. Example The following example verifies that Start_Date is less than End_Date.Shik Mahamood Ali 62 Fires during the Validate the Record process. it fires as the last part of record validation for records with the New or Changed validation status. the chance this code will ** be reusable in other forms we write is pretty low because of dependency on block and item ** names. END IF. Transaction processing includes two phases: • Post: – Writes record changes to base tables – Fires transactional triggers • Commit: Performs database commit Errors result in: • Rollback of the database changes • Error message The Commit Sequence of Events The commit sequence of events (when the Array DML size is 1) is as follows: 1 Validate the form.TRANSACTIONAL TRIGGERS Transactional triggers fire in response to a wide variety of events that occur as a form interacts with the data source. ** Structured this way. Specifically. 4 Validate the block (for all blocks in sequential order).*/ BEGIN IF :Experiment. it's more convenient to check the combination of them once at the record level.
Usage Notes • Use a Pre-Delete trigger to delete the detail record of a master record. 5 Fire the Post-Forms-Commit trigger.Shik Mahamood Ali 63 If it is an inserted record: . • 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. RAISE form_trigger_failure. BEGIN OPEN C1. before base table blocks are processed.Check the record uniqueness.Fire the Pre-Insert trigger. Fire the Post-Update trigger. PRE-DELETE TRIGGER -DECLARE CURSOR C1 IS SELECT ’anything’ FROM S_ORD WHERE customer_id = :S_CUSTOMER. END. END IF. .) Usage Notes: Use a Pre–Commit trigger to perform an action. 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.dummy. Pre-Delete Journaling. If the current operation is COMMIT.Copy Value From Item. such as setting up special locking requirements.id. It fires once for each record that is marked for delete. IF C1%FOUND THEN MESSAGE(’There are orders for this customer!’). anytime a database commit is going to occur. . Commit Triggers Uses 1. . Pre-Insert . implement foreign-key delete rule Fires during the Post and Commit Transactions process. Check the record uniqueness Update the row in the base table or fire the On-Update trigger. .Fire the Post-Insert trigger. ELSE CLOSE C1. even if there are no changes to post. set up special locking Pre-Commit Fires once during commit processing.Insert the row into the base table or fire the On-Insert trigger. 7 Fire the Post-Database-Commit trigger. Pre-Commit: Fires once if form changes are made or uncommitted changes are posted 2. then: 6 Issue an SQL-COMMIT statement. before a row is deleted. Final checks before row deletion 3. Pre-Commit Check user authorization. If it is an updated record: Fire the Pre-Update trigger. FETCH C1 INTO :GLOBAL.
recording the new upper value for the sequence. DECLARE CURSOR next_ord IS SELECT orderid_seq. 4. before a row is inserted. It fires once for each record that is marked for update. Generate sequence numbers. /* ** Insert a row into the audit table */ INSERT INTO ord_audit( orderid. RAISE Form_Trigger_Failure. check constraints Usage Notes: Use a Pre–Insert trigger to perform the following tasks: • Example:1 • change item values keep track of the date a record is created and store that in the record prior to committing This Pre-Insert trigger on the S_ORD block assigns an Order ID from the sequence S_ORD_ID. 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.NEXTVAL FROM dual. */ IF :Order. and then writes a row into an auditing table. USER.dual.OrderId. END IF. auto-generated columns. CLOSE next_ord. check constraints . flagging creation of a new order. which will be written to the ID column when the row is subsequently inserted.id FROM SYS. so that the user does not enter an ID manually. Begin SELECT S_ORD_ID. ** but explicit cursor is more efficient.nextval INTO :S_ORD. You can also assign sequence numbers from a table.id should be No.. END.INTO. Could use SELECT.Shik Mahamood Ali 64 Fires during the Post and Commit Transactions process. operation. End. BEGIN /* ** Fetch the next sequence number from the ** explicit cursor directly into the item in ** the Order record. • Use Post-Insert to update the sequence table. Journaling. It fires once for each record that is marked for insert. Note: The Insert Allowed and Keyboard Navigable properties on :S_ORD...OrderId IS NULL THEN Message(’Error Generating Next Order Id’). If you use this method. /* ** Make sure we populated a new order id ok. Pre-Update Fires during the Post and Commit Transactions process. implement foreign-key update rule. ’New Order’.SYSDATE ). timestamp ) VALUES ( :Order.. Example:2 This example assigns a primary key field based on a sequence number. before a row is updated.OrderId. username. automatically generated columns. */ OPEN next_ord. FETCH next_ord INTO :Order. journaling.
and deletes have been posted to the database. BEGIN /* ** Fetch the old value of discount percentage from the database by CustomerId. On-Commit Fires whenever Oracle Forms would normally issue a database commit statement to finalize a transaction. FETCH old_value INTO old_discount. BEGIN IF Get_Application_Property(DATA_SOURCE) = ’ORACLE’ THEN .SYSDATE ). new_discount NUMBER := :Customer.5% to 20%’ */ oper_desc := ’Changed Discount from ’|| TO_CHAR(old_discount)||’% to ’|| TO_CHAR(new_discount)||’%’.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.INTO but choose an explicit cursor for efficiency. CLOSE old_value. By default. DECLARE old_discount NUMBER. e. /* ** Insert the audit record with timestamp and user */ INSERT INTO cust_audit( custid. • To perform the default processing from this trigger. END IF. Example: This example disables the commit operation when running against a datasource that does not support transaction control. END.USER.Shik Mahamood Ali 65 Usage Notes: Use a Pre–Update trigger to audit transactions. oper_desc VARCHAR2(80). inserts. timestamp ) VALUES ( :Customer. 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.oper_desc. If the application is running against ORACLE. username.CustId.. 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. call to the COMMIT_FORM built–in.Discount_Pct. /* ** If the old and current values are different. We could use SELECT. operation. Example: The following example writes a row into an Audit Table showing old discount and new discount for a given customer. including timestamp and username making the change. We need to do this since the value of :Customer. the commit operation behaves normally.CustId. 5. */ OPEN old_value. ** ’Changed Discount from 13. CURSOR old_value IS SELECT discount_pct FROM customer WHERE CustId = :Customer. this operation occurs after all records that have been marked as updates.g..
Description When called from an On-Insert trigger. BEGIN UPDATE emp SET termination_date = SYSDATE WHERE empno = :Emp. Example: This example updates the employee table to set the Termination_Date. no action is performed */ END. To perform the default Oracle Forms processing from this trigger. ** Trigger: On-Insert */ BEGIN /* ** Check the global flag we setup at form startup */ IF :Global. END IF. replacing the actual database delete of a given row. to delete a record from your form or from the database. To perform the default Form Builder processing from this trigger. Usage Notes • • Use an On-Insert trigger to replace the default Form Builder processing for handling inserted records during transaction posting. On-Insert Fires during the Post and Commit Transactions process when a record is inserted.Shik Mahamood Ali 66 Commit_Form. This built-in is included primarily for applications that will run against a nonORACLE datasource. 6. The trigger fires once for each row that is marked for deletion from the database. perhaps based on a parameter.Empno. Usage Notes: • • Use an On–Delete trigger to replace the default Oracle Forms processing for handling deleted records during transaction posting. inserts the current record into the database during Post and Commit Transactions processing.Using_Transactional_Triggers = 'TRUE' THEN User_Exit('my_insrec block=EMP'). rather than actually deleting the employee from the database. /* ** Otherwise. 7. Syntax PROCEDURE INSERT_RECORD. . it fires after the Pre-Insert trigger fires and before the Post-Insert trigger fires. /* ** otherwise. END. include a call to the INSERT_RECORD built-in. It fires once for each row that is marked for insertion into the database. /* ** Built-in: INSERT_RECORD ** Example : Perform Form Builder standard insert processing ** based on a global flag setup at startup by the ** form. Specifically. it fires after the Pre–Delete trigger fires and before the Post–Delete trigger fires. Specifically. On-Delete Fires during the Post and Commit Transactions process. that is. include a call to the DELETE_RECORD built–in. do the right thing. */ ELSE Insert_Record. when Form Builder would normally insert a record in the database.
.) UPDATE base_table SET base_column = :base_item. This built-in is included primarily for applications that run against a non-ORACLE data source. Specifically. • Form Builder uses and retrieves ROWID.. include a call to the UPDATE_RECORD built–in.. End. Begin UPDATE RECORD. when Oracle Forms would normally update a record in the database. . When called from an On-Update trigger.Did_DB_Commit = 'FALSE'). 8.Did_DB_Commit'). but before the transaction has been finalized by issuing the Commit. after the database commit occurs. base_column = :base_item. END. updates. Note that the Post-Forms-Commit trigger fires after inserts.Form_Status = 'QUERY' AND :Global. initiates the default Form Builder processing for updating a record in the database during the Post and Commit Transaction process. • The Update Changed Columns Only and Enforce Column Security properties affect UPDATE statements. and deletes have been posted to the database. RETURN (:System. To perform the default Oracle Forms processing from this trigger. Usage Notes: • • Use an On–Update trigger to replace the default Oracle Forms processing for handling updated records during transaction posting.. :base_item..WHERE ROWID = :ROWID DELETE FROM base_table WHERE ROWID = :ROWID DML Statements Issued During Commit Processing Rules: • DML statements may fire database triggers. base_column. The Post-DatabaseCommit Trigger fires after Form Builder issues the Commit to finalize the transaction. END.. 9.'Global. .Shik Mahamood Ali END IF. It fires once for each row that is marked for update in the form.. On-Update 67 Fires during the Post and Commit Transactions process. it fires after the Pre–Update trigger fires and before the Post–Update trigger fires. Usage Notes Use a Post-Database-Commit trigger to perform an action anytime a database commit has occurred.) VALUES ( :base_item. DML Statements Issued During Commit Processing INSERT INTO base_table ( base_column. Post – Database Commit Description Fires once during the Post and Commit Transactions process. • Locking statements are not issued.. Example /* ** FUNCTION recs_posted_and_not_committed ** RETURN BOOLEAN IS BEGIN Default_Value('TRUE'.
END. Post – Form .'Global. updates. USER ). END.1 Begin INSERT INTO delete_audit (id.Shik Mahamood Ali */ BEGIN :Global.Did_DB_Commit := 'FALSE'. Example . 11. */ BEGIN :Global. IF SQL%NOTFOUND THEN MESSAGE(’Record not found in database’). updates. /* FUNCTION recs_posted_and_not_committed RETURN BOOLEAN IS BEGIN Default_Value('TRUE'. RAISE form_trigger_failure. or deletes.Did_DB_Commit := 'FALSE'. End. Usage Notes • • Use a Post-Forms-Commit trigger to perform an action. anytime a database commit is about to occur. It fires once for each row that is deleted from the database during the commit process.id. who_did_it)VALUES ( :S_ORD. RETURN (:System. END. 68 Post-Database-Commit Determines if commit was successful. SYSDATE. timestamp. Post – Delete Fires during the Post and Commit Transactions process. form or block Usage Notes: Use a Post–Delete trigger to audit transactions. If the operator or the application initiates a Commit when there are no records in the form have been marked as inserts. after a row is deleted. uncommitted changes 10. determines if there are posted.Did_DB_Commit = FALSE'). such as updating an audit trail.Form_Status = 'QUERY'AND :Global. .Did_DB_Commit'). without posting changes to the database. If there are records in the form that have been marked as inserts.2 Begin Delete from S_ORD SET WHERE id = :S_ORD. Example . Form Builder fires the Post-Forms-Commit trigger immediately.Commit Fires once during the Post and Commit Transactions process.id. 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. 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. or deletes.
IF SQL%NOTFOUND THEN MESSAGE(’Record not found in database’). Post – Insert Fires during the Post and Commit Transactions process.insert_tot)+1). It fires once for each row that is updated in the database during the commit process. Example . • • • Use a Post-Insert trigger to audit transactions.username).id. LOG_USER) VALUES(:S_DEPT. Usage Notes: Use a Post–Update trigger to audit transactions.Shik Mahamood Ali Else 69 Messafe(SQL%rowcount|| “ rows Deleted”).along with a time stamp and the user who performed the update. Example 1 Keeping an Audit Trail :GLOBAL. End. Query Processing Triggers Uses . timestamp. Gather statistics on applied changes. END IF. include EXCEPTION section in trigger. Post – Update Fires during the Post and Commit Transactions process. End. EXCEPTION WHEN OTHERS THEN MESSAGE(’Error! ’. Example . END IF. RAISE form_trigger_failure. Write changes to nonbase tables.1 Begin INSERT INTO update_audit (id. after a row is updated.id. End. who_did_it)VALUES ( :S_ORD.:GLOBAL. 13.insert_tot := TO_CHAR(TO_NUMBER(:GLOBAL. It fires once for each record that is inserted into the database during the commit process. Example 2 To handle exceptions.||SQLERRM). 12. USER ). This Post-Update trigger writes the current record ID to the UPDATE_AUDIT table.2 Begin UPDATE S_ORD SET date_shipped = SYSDATE WHERE id = :S_ORD.id. SYSDATE. Post-Insert trigger: Begin INSERT INTO LOG_TAB (LOG_VAL. End. just after a record is inserted.
USER. and then writes a row into an auditing table. Usage Notes • Use an On-Select trigger to open and execute the database cursor. use this trigger when you are retrieving data from a non-ORACLE data source. */ .SYSDATE ). parse. and execute phases. parse. BEGIN /** Fetch the next sequence number from the Explicit cursor directly into the item in the Order record. flagging creation of a neworder. Could use SELECT. the On-Select trigger is used to call a user exit. On . On-Select replaces open cursor. ** but explicit cursor is more efficient.NEXTVAL FROM dual. operation. CLOSE next_ord..LAST_QUERY Fires after Form Builder has constructed the block SELECT statement based on the query conditions. username. END IF. /** Insert a row into the audit table INSERT INTO ord_audit( orderid. include a call to the SELECT_RECORDS built-in. but before the statement is actually issued. to perform a query against a database. 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. To perform the default Form Builder processing from this trigger. ELSE /* ** Perform the default Form Builder task of opening the query. 'Query.' and a built-in subprogram. after Form Builder constructs the SELECT statement to be issued.. Specifically. END IF. END. to identify the records in the database that match the current query criteria. DECLARE CURSOR next_ord IS SELECT orderid_seq.’New Order’. This example assigns a primary key field based on a sequence number. */ OPEN next_ord. IF Form_Failure OR Form_Fatal THEN ABORT_QUERY. but before it issues this statement Use a Pre-Select trigger to prepare a query prior to execution against a non-ORACLE data source.OrderId.OrderId IS NULL THEN Message(’Error Generating Next Order Id’). 15. • Example .Shik Mahamood Ali 14. Note that the SELECT statement can be examined in a Pre-Select trigger by reading the value of the system variable SYSTEM.1 In the following example. Begin IF Get_Application_Property(DATASOURCE) = 'DB2' THEN User_Exit ( 'Query' ).OrderId. timestamp ) VALUES ( :Order.INTO.Select Fires when Form Builder would normally execute the open cursor. RAISE Form_Trigger_Failure. SELECT_RECORDS. Pre – Select 70 Fires during Execute Query and Count Query processing. IF :Order. FETCH next_ord INTO :Order. and execute phases of a query.
empno := emprow. On–Fetch: DECLARE j NUMBER := Get_Block_Property(blk_name. :Emp. 16. or after the successful execution of the On-Select trigger. – The query is closed by the user or by ABORT_QUERY. Post-Select Trigger Description Fires after Form Builder has constructed and issued the block SELECT statement. – It raises FORM_TRIGGER_FAILURE.j LOOP /* ** Try to get the next row. On – Count Fires when Form Builder would usually perform default Count Query processing to determine the number of rows that match the query conditions . End.rowid := emprow.Shik Mahamood Ali Select_Records. :Emp. It fires before any records are actually retrieved through fetch processing.) • On-Fetch continues to fire until: – It fires without executing CREATE_QUERIED_RECORD. 71 16. 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. but before it fetches the records The Post-Select trigger fires after the default selection phase of query processing.ROWID.EMPNO. RECORDS_TO_FETCH). END LOOP. The trigger will fire once for each record that is to be fetched. emprow emp%ROWTYPE..ename := emprow. 15. :Emp. END. BEGIN FOR ctr IN 1.ENAME. Create_Queried_Record. IF form_fatal OR form_failure THEN raise form_trigger_failure. */ EXIT WHEN NOT MyPackage.Get_Next_Row(emprow). 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. END IF. END IF.
the message reports 0 records identified. */ BEGIN Count_Query. Decide whether to use this Built-in or a user ** exit based on a global flag setup at startup by the form. Usage Notes • Use an On-Count trigger to replace default Count Query processing in an application running against a non-ORACLE data source. Example . */ User_Exit('my_count'). BEGIN j := Recs_Returned('DEPT'. END.DNAME')). END. * Trigger: On-Count */ BEGIN /* ** Check the global flag we set during form startup */ IF :Global. and sets the Query_Hits property appropriately.j). perhaps based on a parameter. • If you are replacing default processing. 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. • 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.QUERY_HITS.Name_In('DEPT. . Example 3 /* ** Built-in: COUNT_QUERY ** Example: Perform Form Builder count query hits processing. In such a case. Example 2 /* ** Built-in: COUNT_QUERY ** Example: Display the number of records that will be retrieved ** by the current query.Shik Mahamood Ali 72 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. include a call to the built-in. Form Builder issues the standard query hits message: FRM-40355: Query will retrieve <n> records.1 This example calls a user-named subprogram to count the number of records to be retrieved by the current query criteria. Set_Block_Property('DEPT'. DECLARE j NUMBER. When the On-Count trigger completes execution.HITS item. • To perform the default Form Builder processing from this trigger.Using_Transactional_Triggers = 'TRUE' THEN /* ** User exit returns query hits count back into the ** CONTROL.
Shik Mahamood Ali 73 /* ** Deposit the number of query hits in the appropriate ** block property so Form Builder can display its normal ** status message. Usage Notes • When a SEQUENCE is used as a default item value. END.Trigger_Block. do the right thing. do the right thing. ** Trigger: On–Sequence–Number */ BEGIN /* ** Check the global flag we setup at form startup */ IF :Global. the On-Check-Unique trigger fires when Form Builder normally . /* ** Otherwise.On-Sequence-Number Trigger Description Fires when Form Builder would normally perform the default processing for generating sequence numbers for default item values. */ Set_Block_Property(:System. 17. END IF. */ ELSE Count_Query. Suppress or override this functionality with an On-Sequence-Number trigger. perhaps based on a parameter.QUERY_HITS. /* ** Otherwise.Using_Transactional_Triggers = ’TRUE’ THEN User_Exit(’my_seqnum seq=EMPNO_SEQ’). call the GENERATE_SEQUENCE_NUMBER built-in. Form Builder queries the database to get the next value from the SEQUENCE whenever the Create Record event occurs.hits). END IF. */ ELSE Generate_Sequence_Number. 18.:control. On-Check-Unique Trigger Description During a commit operation. To perform the default Form Builder processing from this trigger. • 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. END. 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.
It fires once for each record that has been inserted or updated. 19. RAISE Form_Trigger_Failure. END IF.'). When a block has the PRIMKEYB property set to Yes. END. or when the operator or the application aborts the query. The On-Close trigger fires automatically when the ABORT_QUERY built-in is called from an On-Select trigger. DECLARE CURSOR chk_unique IS SELECT 'x' FROM dept WHERE deptno = :dept. Example The following example releases memory being used by a user-defined data access method via the transactional triggers. Form Builder closes a query when all of the records identified by the query criteria have been fetched. Replaces the default processing for checking record uniqueness. to close files. 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. close cursors. Form Builder always checks for unique primary key values. FETCH chk_unique INTO tmp.deptno. BEGIN IF NOT my_data source_open('DX110_DEPT') THEN my_datasource_close('DX110_DEPT'). CLOSE chk_unique. tmp VARCHAR2(1). Usage Notes To perform the default processing from this trigger. For a record that has been marked for insert. specifically. Form Builder displays message FRM-40600: Record has already been inserted. On-Close Trigger Description Fires when an operator or the application causes a query to close. If a duplicate row is found. and free memory. call the CHECK_RECORD_UNIQUENESS built-in. . IF tmp IS NOT NULL THEN Message('This department already exists. Usage Notes • • Use an On-Close trigger after using the On-Select or On-Fetch triggers. END IF. By default. BEGIN OPEN chk_unique. by default. Form Builder checks for unique primary key values only if one or more items that have the Primary Key item property have been modified. In the case of an update. Form Builder.Shik Mahamood Ali 74 checks that primary key values are unique before inserting or updating a record in a base table. 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-Close trigger augments the normal Form Builder "close cursor" phase of a query.
Form Builder enforces column security by querying the database to determine the base table columns to which the current form operator has update privileges. include a call to the .ENABLED. Form Builder makes the corresponding base table items in the form non-updateable by setting the Update Allowed item property Off dynamically.ENABLED.UPDATEABLE.on_or_off). BEGIN IF NOT role_is_set('SUPERUSER') THEN on_or_off := PROPERTY_OFF. 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. Usage Notes To perform the default processing from this trigger. For columns to which the operator does not have update privileges.on_or_off). To perform default Form Builder processing from this trigger. Usage Notes Use an On-Rollback trigger to replace standard Form Builder rollback processing.UPDATEABLE. Set_Item_Property(itm_id. 21.Comm'). END. END IF. By default. to roll back a transaction to the last savepoint that was issued.Sal'). DECLARE itm_id Item. unless the SUPERUSER role is enabled. Set_Item_Property(itm_id. 75 20. on_or_off NUMBER. Only users with the user-defined SUPERUSER role can change these number fields. Set_Item_Property(itm_id. ELSE on_or_off := PROPERTY_ON. itm_id := Find_Item('Emp. call the ENFORCE_COLUMN_SECURITY built-in.on_or_off). Set_Item_Property(itm_id. itm_id := Find_Item('Emp.Shik Mahamood Ali END. On-Rollback Trigger Description Fires when Form Builder would normally issue a ROLLBACK statement.on_or_off). processing each block in sequence. Form Builder performs this operation at form startup. Example The following example sets salary and commission text items in the current block to disabled and non-updateable.
You can supply a NULL command to this trigger to bypass the connection to a data source.Using_Transactional_Triggers = 'TRUE' THEN User_Exit('my_rollbk name='||sp_name). BEGIN /* Get the name of the savepoint to which Form Builder needs to ** rollback. Pre-Logon Trigger Fires just before Form Builder initiate a logon procedure to the data source. Usage Notes: Use an On–Logon trigger to initiate a logon procedure to a non–ORACLE data source. (NULL = Full Rollback)*/ sp_name := Get_Application_Property(SAVEPOINT_NAME). END IF . if you want to create an application that does not require a data source.Shik Mahamood Ali ISSUE_ROLLBACK built-in. /* ** Check the global flag we setup at form startup */ IF :Global. un NUMBER. J. • • • Pre–Logon and Post–Logon triggers fire as part of the logon procedure. ** perhaps based on a parameter. pw VARCHAR2(30). ISSUE_ROLLBACK examples 76 /* ** Built-in: ISSUE_ROLLBACK ** Example: Perform Form Builder standard Rollback processing. 2. ELSE Issue_Rollback(sp_name). tries NUMBER:=3. particularly to a nonORACLE data source. To perform the default Oracle Forms processing from this trigger. ** Decide whether to use this built-in based on a ** global flag setup at startup by the form. DECLARE connected BOOLEAN:=FALSE. ** Trigger: On-Rollback */ DECLARE sp_name VARCHAR2(80). cs VARCHAR2(30). On-Logon Trigger Fires once per logon when Oracle Forms normally initiates the logon sequence. . END. include a call to the LOGON built–in. Usage Notes Use a Pre-Logon trigger to prepare the form for the logon procedure.LOGON TRANSACTION TRIGGERS 1.
END IF. 4. IF NOT CONNECTED THEN MESSAGE(‘Too many tries’). pw:=GET_APPLICATION_PROPERTY( PASSWORD ). the results are undefined. POST-LOGON TRIGGER Description Fires after either of the following events: • • The successful completion of Form Builder default logon processing. particularly a non-ORACLE data source. 3.'YYYYMMDDHH24MISS')). IF FORM_SUCESS THEN Connected:=TRUE. END IF.Shik Mahamood Ali BEGIN 77 SET_APPLICATION_PROPERTY(CURSOR_STYLE. The successful execution of the On-Logon trigger. WHILE CONNECTED = FALSE AND tries > 0 LOOP LOGON_SCREEN. which for security reasons is outside the database.’DEFAULT’). Because the form is no longer accessible at this point. LOGON( un. the COPY built-in cannot be called from a Pre-Logout trigger because Pre-Logout fires after the Leave the Form event. END. . Usage Notes • • Use a Pre-Logout trigger to prepare the form for logging out from the data source. Example This example calls a user exit to log the current username and time to an encrypted audit trail file on the file system. END LOOP. For example. RAISE FORM_TRIGGER_FAILURE. cs:= GET_APPLICATION_PROPERTY( CONNECTION_STRING ). Tries:=tries-1. the COPY operation is not possible. Pre-Logout Trigger Fires once before Form Builder initiate a logout procedure. BEGIN User_Exit('LogCrypt '|| USER||' ' ||TO_CHAR(SYSDATE. un:=GET_APPLICATION_PROPERTY( USERNAME ). pw || ‘@’ || CS . FALSE ). If you call certain built-ins from within one of the Logout triggers. END.
MOUSE TRIGGERS 1. If you call certain built-ins from within one of the Logout triggers. For example. To perform the default Form Builder processing from this trigger. when the mouse is clicked within any canvas or item in the form if attached to a block. a COPY operation is not possible. 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.Shik Mahamood Ali 5. BEGIN User_Exit(’LogCrypt ’||USER||’ ’ || TO_CHAR(SYSDATE. This example calls a user exit to log the current username and time to an encrypted audit trail file on the file system. Because the form is no longer accessible. the results are undefined. J. If you call certain built-ins from within one of the Logout triggers. Because the form is no longer accessible. 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.’YYYYMMDDHH24MISS’)). the results are undefined. When-Mouse-Click Trigger Description Fires after the operator click the mouse if one of the following events occurs: • • if attached to the form. include a call to the LOGOUT built-in. On-Logout Trigger 78 Fires when Form Builder normally initiates a logout procedure from Form Builder and from the RDBMS. you cannot call the COPY built-in from a Pre-Logout trigger because Pre-Logout fires after the Leave the Form event. Usage Notes • • • Use an On-Logout trigger to replace the default logout processing either from the RDBMS or from a non-ORACLE data source. a COPY operation is not possible. Post-Logout Trigger Description Fires after either of the following events: • • Form Builder successfully logs out of ORACLE. END. when the mouse is clicked within any item in the block . 6. For example.
a product information window must appear. 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. an online help window must appear. 3. When-Mouse-DoubleClick Trigger examples Example Assume that an application requires Behavior A when the operator clicks the mouse and Behavior B when the operator double-clicks the mouse.Shik Mahamood Ali 79 • if attached to an item. When-Mouse-Down Trigger Description . if the operator clicks the mouse. 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 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. If the operator double-clicks the mouse. 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 double-clicked within any item in the block if attached to an item. when the mouse is double-clicked within any canvas or item in the form if attached to a block. 2. For example. 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.
Assume also that your application contains two canvases. begin :GLOBAL. Note: The mouse down event is always followed by a mouse up event. Finally. so the user is never able to click on those items. 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. Iconic buttons and items on the canvas below the initial window cannot be selected. when the mouse is pressed down within any item in the block if attached to an item. when the operator moves the mouse out of Canvas_Two. 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. Do not use the When-Mouse-Enter trigger on a canvas that is larger than the window. Alert_One will appear again unnecessarily if the operator subsequently enters Canvas_One with the mouse. any When-Mouse-Leave triggers associated with this event will fire. In addition. assume that the mouse has entered Canvas_One causing the When-Mouse-Enter trigger to fire which in turn causes Alert_One to appear. 4. when the mouse enters any canvas or item in the form if attached to a block.Shik Mahamood Ali 80 Fires after the operator presses down the mouse button if one of the following events occurs: • • • if attached to the form. When the operator dismisses the message box. Be careful when calling a modal window from a When-Mouse-Enter trigger. This may not be the desired behavior.save_item_name := :SYSTEM.CURSOR_ITEM. Doing so may cause the modal window to appear unnecessarily. The user is able to scroll the canvas to see the items. assume that your When-Mouse-Enter trigger causes Alert_One to appear whenever the mouse enters Canvas_One. when the mouse is pressed down within any canvas or item in the form if attached to a block. when the mouse enters any item in the block if attached to an item. the trigger fires and returns focus to the previous target. However. 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. but appear side by side on the screen. assume that Alert_One displays within Canvas_Two's border. Canvas_One and Canvas_Two do not overlap each other. Further. For example. Changing a tooltip's property in a When-Mouse-Enter trigger cancels the tooltip before it is ever shown. . GO_ITEM(’s_ord.id’). Canvas_One and Canvas_Two. as soon as the mouse enters that area.
When-Mouse-Move Trigger Description Fires each time the mouse moves if one of the following events occurs: • • • if attached to the form. END IF. WHEN-MOUSE-ENTER at Form Level begin 81 IF :SYSTEM. The When-Mouse-Move trigger may have performance implications because of the number of times this trigger can potentially fire. End. when the mouse moves within any canvas or item in the form if attached to a block. GO_ITEM(:GLOBAL. 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. when the mouse moves within any item in the block if attached to an item.show_help_button := ’?’.Shik Mahamood Ali SHOW_VIEW(’cv_help’). when the mouse leaves any item in the block if attached to an item.show_help_button begin HIDE_VIEW(’cv_help’). 5. 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. 7.MOUSE_CANVAS = ’CV_ORDER’ THEN :control. 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. 6. WHEN-MOUSE-LEAVE trigger on control. End. When-Mouse-Up Trigger Description Fires each time the operator presses down and releases the mouse button if one of the following events occurs: . End.save_item_name).
the mouse up trigger will fire for Item_One. assume that there is a When-Mouse-Up trigger attached to Item_One. DO_KEY built-in Executes the key trigger that corresponds to the specified built-in subprogram. Note: You can write user–named PL/SQL subprograms to perform almost any task for which you might use a user–named trigger. For example. 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. This behavior is analogous to pressing the corresponding function key.) In the menu PL/SQL. the scope of a user-named trigger is the definition level and below. If no such key trigger exists. you must call the EXECUTE_TRIGGER built–in procedure. The mouse up event is always associated with the item that received the mouse down event. which is defined in a different document. (User-named subprograms defined in a form cannot be called directly from menu PL/SQL. If the operator presses down the mouse on Item_One. Each user–named trigger defined at the same definition level must have a unique name. when the mouse up event is received within any item in a block • if attached to an item. K. as shown here: Execute_Trigger(’my_user_named_trigger’).Shik Mahamood Ali 82 • if attached to the form. Syntax PROCEDURE DO_KEY . and then call explicitly from other triggers or user–named subprograms. rather than for Item_Two. but then releases the mouse on Item_Two.OTHER TRIGGERS 1. the trigger defined at the lowest level has precedence. Create a user-named trigger to execute user-named subprograms defined in a form document from menu PL/SQL commands and user-named subprograms. It is most practical to define user-named triggers at the form level. As with all triggers. which in turn calls the user-named subprogram defined in the current form. then the specified subprogram executes. When more than one user-named trigger has the same name. when the mouse up event is received within any canvas or item in a form • if attached to a block. call the EXECUTE_TRIGGER built-in to execute a usernamed trigger. To execute a user–named trigger. 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.
Using_Transactional_Triggers = 'TRUE' THEN User_Exit('my_savept name='||sp_name). not key names: DO_KEY(ENTER_QUERY). Savepoint_Name returns the name of the savepoint to which Form Builder would roll back. When Savepoint Mode is Off. /* Otherwise. /* Check the global flag we setup at form startup */ IF :Global. use the EXECUTE_TRIGGER built-in: EXECUTE_TRIGGER('KEY_F11'). 2. END IF. BEGIN /* Get the name of the savepoint Form Builder needs to issue */ sp_name := Get_Application_Property(SAVEPOINT_NAME). do the right thing.consequently. By default. END. Suppress default savepoint processing by setting the Savepoint Mode form document property to Off. the On-Savepoint trigger never fires.perhaps based on a parameter. DO_KEY examples /* ** Built-in: DO_KEY ** Example: Simulate pressing the [Execute Query] key. In an On-Savepoint trigger. Usage Notes To perform default Form Builder processing from this trigger. To accept a specific key name. ** Trigger: On-Savepoint */ DECLARE sp_name VARCHAR2(80). DO_KEY restrictions DO_KEY accepts built-in names only. */ ELSE Issue_Savepoint(sp_name). ** Decide whether to use this built-in based on a global flag setup at startup by the form. Form Builder does not issue savepoints and. On-Savepoint Trigger Fires when Form Builder would normally issue a Savepoint statement. include a call to the ISSUE_SAVEPOINT built-in. Post-Change Trigger . END. if no On-Savepoint trigger were present. Form Builder issues savepoints at form startup. */ BEGIN Do_Key('Execute_Query'). 3. In an On-Rollback trigger . and at the start of each Post and Commit Transaction process. /* ** Built-in: ISSUE_SAVEPOINT ** Example: Perform Form Builder standard savepoint processing. the Savepoint_Name application property returns the name of the next savepoint that Form Builder would issue by default.Shik Mahamood Ali 83 (built-in_subprogram_name VARCHAR2).
perhaps based on a parameter.Non_Oracle_Datasource = 'TRUE' THEN . Also. • • • /* ** Built-in: LOCK_RECORD ** Example: Perform Form Builder standard record locking on the queried record which has just been deleted or updated. Usage Notes • • The Post-Change trigger is included only for compatibility with previous versions of Form Builder. Decide whether to use default processing or a user exit by consulting a global flag setup at startup by the form. the trigger fires only the first time the operator tries to modify an item in the record. If you want to circumvent this situation and effectively get rid of the Post-Change trigger. and the item is not NULL. To perform the default Oracle Forms processing from this trigger. Given such changes. In this case. such as when an operator presses a key to modify data in an item. for every row that is to be locked. you must include a Post-Query trigger in addition to your When-Validate-Item trigger. Form Builder fetches a non-NULL value into an item.Shik Mahamood Ali 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. use On–Lock if you are accessing a non–ORACLE data source directly. In other words. Use this trigger to lock underlying tables for non–updateable views. the trigger fires once. 3. you can use the On–Lock trigger to speed processing by bypassing all lock processing. For example. not by way of Open Gateway. The trigger fires between the key press and the display of the modified data. the When-ValidateItem trigger does not fire. ** Trigger: On-Lock */ BEGIN /* ** Check the global flag we set up at form startup */ IF :Global. See "Usage Notes" below. include a call to the LOCK_RECORD built–in. if you are designing an application for use on a single–user system. Its use is not recommended in new applications. On-Lock Trigger Fires whenever Oracle Forms would normally attempt to lock a row. An operator returns a value into an item by making a selection from a list of values. You can use Post-Query to make changes to the fetched database values. The Post-Query trigger does not have the restrictions of the Post-Change trigger. The trigger does not fire during subsequent modifications to items in the same record. Form Builder marks the corresponding items and records as changed. When the On–Lock trigger fires as a result of an operator trying to modify data. Usage Notes: • Use an On–Lock trigger to replace the default Oracle Forms processing for locking rows.
Pre-Popup-Menu Trigger This trigger is called when a user causes a pop-up menu to be displayed. the query stored procedure has to use those values to filter the data. Think of this as an On-Update trigger that is called by the system instead of doing default update operations.) Actions defined for this trigger are performed before the pop-up menu is displayed.custom_item_event. 6. Think of this as an On-Query trigger that is called by the system instead of doing default query operations. do the right thing. The system variable SYSTEM. Then. This trigger is called when a query operation is necessary. When-Custom-Item-Event Trigger Fires whenever a VBX control sends an event to Oracle Forms. Update-Procedure Trigger Automatically created by Form Builder when the update data source is a stored procedure. any of the items may be used. Example: This is an example of a procedure that can be called when Oracle Forms fires the When–Custom–Item–Event Trigger. /* ** Otherwise. 5. */ ELSE Lock_Record. 7. this occurs when a user presses the right mouse button.CUSTOM_ITEM_EVENT stores the case–sensitive name of the event that occurred. . Usage Notes When constructing a query. (In a Microsoft Windows environment. but the Query Data Source Columns property must be set so that those items can be passed to the query stored procedure. BEGIN TabEvent := :system.CUSTOM_ITEM_EVENT_PARAMETERS stores a parameter name that contains the supplementary arguments for an event that is fired by a VBX control. Usage Notes Use this trigger to enable or disable menu items on a pop-up menu before it is displayed. This means that the enter query mode does not happen automatically unless you specify it. 8. and the system variable SYSTEM.Shik Mahamood Ali 85 User_Exit('my_lockrec block=EMP'). END IF. Query-Procedure Trigger Automatically created by Form Builder when the query data source is a stored procedure. TabNumber Number. Usage Notes: Use a When–Custom–Item–Event trigger to respond to a selection or change of value for a VBX control. END. DECLARE TabEvent varchar2(80). This trigger is called when a update operation is necessary.
For example. the trigger will fire when the mouse or keyboard is used to navigate between tab pages. When-Tab-Page-Changed does not fire when the tab page is changed programmatically.to uppercase (to indicate to end users if they already have ** navigated to the tab page): */ DECLARE tp_nm VARCHAR2(30). tp_id TAB_PAGE. When-Tab-Page-Changed Fires whenever there is explicit item or mouse navigation from one tab page to another in a tab canvas. tp_lb VARCHAR2(30). When-Form-Navigate Trigger Fires whenever any peer form navigation takes place. identify the ** tab selected. it does not respond to implicit navigation. END IF.Get_Property(’TABCONTROL’. This is an example of a procedure that can be called when Oracle Forms fires the When–Form– Navigate Trigger. but on different tab pages. 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. and use the user–defined Goto_Tab_Page procedure to navigate to the selected page. label). BEGIN if (GET_WINDOW_PROPERTY(win_id.WINDOW_STATE. • Example /* Use a When-Tab-Page-Changed trigger to dynamically change a tab page's label from lower. BEGIN tp_nm := GET_CANVAS_PROPERTY('emp_cvs'. 10. END. else SET_WINDOW_PROPERTY(win_id. . When-Tab-Page-Changed fires only when tab page navigation is explicit. */ IF (UPPER(TabEvent) = ’CLICK’) THEN TabNumber := VBX.Shik Mahamood Ali 86 /* ** After detecting a Click event.WINDOW_STATE. DECLARE win_id WINDOW := FIND_WINDOW(’WINDOW12’). 9. 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. Goto_Tab_Page(TabNumber). tp_lb := GET_TAB_PAGE_PROPERTY(tp_id.WINDOW_STATE) = ’MAXIMIZE’ THEN SET_WINDOW_PROPERTY(win_id.MAXIMIZE).MINIMIZE). tp_id := FIND_TAB_PAGE(tp_nm).’CurrTab’). end if. Usage Notes • • Use a When-Tab-Page-Changed trigger to perform actions when any tab page is changed during item or mouse navigation. topmost_tab_page). END.
ELSE null. a list of available choices appears.TRIGGER_NODE is the node the user clicked on. 11. No programmatic action will cause the When-Tree-Node-Activated trigger to fire. Usage Notes • SYSTEM. allowing the operator to view and select undisplayed values. label.TRIGGER_NODE returns a value of type NODE.TRIGGER_NODE is the node the user clicked on. a vertical scroll bar appears. END IF. Usage Notes • • SYSTEM. 13. Defining list items A list item displays a predefined set of choices that Ø are mutually exclusive Ø can be displayed as either a poplist.Shik Mahamood Ali 87 IF tp_lb LIKE 'Sa%' THEN SET_TAB_PAGE_PROPERTY(tp_id.TRIGGER_NODE is the node the user clicked on. SYSTEM. 'VACATION').TRIGGER_NODE returns a value of type NODE.TRIGGER_NODE returns a value of type NODE. 12. The combo box list item appears as an empty box with an icon to the right. ELSIF tp_lb LIKE 'Va%' THEN SET_TAB_PAGE_PROPERTY(tp_id. or combo box LIST ITEM Poplist Text List DESCRIPTION Combo Box Appears initially as a single field (similar to a text item field). • No programmatic action will cause the When-Tree-Node-Selected trigger to fire. Only end-user action will generate an event. Unlike the poplist or the text list style list items. The user can enter text directly into the combo field or click the list icon to display a list of available values. the combo box style list item will display fixed values and accept one operator-entered value. SYSTEM. 'SALARY'). Usage Notes • • SYSTEM. When-Tree-Node-Activated Trigger Fires when an operator double-clicks a node or presses Enter when a node is selected. Only enduser action will generate an event. END. Only end-user action will generate an event. . When-Tree-Node-Expanded Trigger Fires when a node is expanded or collapsed. label. SYSTEM. text list. When the operator selects the list icon. Combines the features found in list and text items. When the text list contains values that cannot be displayed (due to the displayable area of the item). When-Tree-Node-Selected Trigger Fires when a node is selected or deselected. Appears as a rectangular box which displays a fixed number of values. No programmatic action will cause the When-Tree-Node-Expanded trigger to fire.
Shik Mahamood Ali 88 .