Chapter 5 Introduction To Form Builder
Lesson C Objectives Use sequences to automatically generate primary key values in a form Create lists of values (LOVs) to provide lists for foreign key values Describe the different form items that you can use to enter and modify data values 2
Form Triggers A form trigger is a program unit in a form that runs in response to an event, which is: A user action - such as clicking a button Or, a system action – such as loading the form or exiting the form You associate form triggers with specific form objects Triggers can be associated with: An entire form (form level) A block (block level) A specific form item (item level) 3
Form Triggers Creating a trigger: select the form or form item event type the trigger code Referencing a form item in PL/SQL code: :block_name.item_name Triggers are compiled before a form is run 4
Using Sequences in Forms To create a trigger that automatically inserts the next sequence value into a text item whenever the user creates a new block record, we use a block event called WHEN-CREATE-RECORD Trigger PL/SQL code: SELECT sequence_name.NEXTVAL INTO :block_name.item_name FROM DUAL; 5
PL/SQL Editor The PL/SQL Editor provides an environment for writing, compiling, and editing PL/SQL programs Components: Name list shows the name of the current program unit allows you to access other program units Type list Shows the program unit type Object list Shows the object to which the program unit is attached and the object level in the Object Navigator 6
PL/SQL Editor Source code pane Provides a text editor in which you can type PL/SQL program statements Status Line (status bar) Displays the program unit’s current modification status Displays the program unit’s current compile status Toolbar Provides buttons such as compile PL/SQL, revert PL/SQL code, undo, redo, indent, and outdent 7
PL/SQL Editor 8
Trigger Syntax Errors When error occurs in a program unit, the PL/SQL Editor’s compilation messages pane displays the line number of the error, the error message, and correction suggestions 9
Form Lists of Values (LOVs) 10 A list of Values (LOV) displays a list of possible data values for a text item The LOV display is the dialog box that displays possible choices for a form text item The LOV display derives its data from a record group, which is a form object that represents data in a tabular format
Form Lists of Values (LOVs) LOV display LOV command button 11
Creating an LOV You can create a new LOV in two ways: Using the LOV Wizard Manually by creating an LOV object and a new record group in the Object Navigator 12
LOV Wizard Steps 1. Specify the LOV display values 2. Format the LOV display 3. Attach the LOV to a text item 4. Change the new LOV and record group default names to descriptive names in the Object Navigator 5. Create an optional command button to open the LOV display 13
LOV Wizard Pages LOV Source page Select whether to create a new record group or use an existing record group SQL Query page Enter the SQL query that retrieves the records that appear in the LOV display Build a SQL query button using a visual tool called Query Builder Import a query from a text file Column Selection page Specifies which record group columns appear in the LOV display 14
LOV Wizard Pages Column Display page Format the LOV fields LOV Display page Specify LOV display title, size, and position Advanced Options page Specify how many records the LOV retrieves Items page Specifies the text item to which the LOV is attached Finish page Signals that the LOV Wizard has successfully created the new LOV 15
Adding a Command Button to Open the LOV Display Users can open the LOV display by placing the insertion point in the text item associated with the LOV, and then pressing CTRL+L You can create a command button to allow users to open the LOV display Drawing the button on the canvas using Button tool on the tool palette Configuring a form button item by modifying the Name property and the Label property Creating an associated button trigger that contains the commands to make the button operational 16
Representing Data Values Using Other Item Types 17 Alternate Form Input Items Radio buttons Check boxes
Radio Buttons You can use radio buttons (option buttons) to represent data fields whose values must be one a small set of mutually exclusive selections In Forms Builder, individual radio buttons exist within a radio group a user can select only one button in a radio group at a time Each radio button has an associated data value, and the radio group has the data value of the currently selected radio button 18
Radio Groups 19 Radio group Individual related radio buttons
Creating a Radio Group Create the form using the Data Block and Layout Wizards 2. Open the item Property Palette, and change the Item Type value to Radio Group 3. Draw and format the radio buttons on the canvas 4. Modify the radio button properties 5. Modify the radio group properties
Important Radio Button Properties 21 Name: how the button is referenced within the form Label: description that appears next to the button on the canvas Radio Button Value: associated data value in the database
Important Radio Group Properties 22 Name: how the radio group is referenced within the form Initial Value: data value of the radio button within the radio group that is selected when the form first appears
Check Boxes Used to represent fields that can have one of two values Check box caption is interpreted as TRUE or FALSE If checked, caption is true If cleared, caption is false 88
Check Box Example 89
Creating a Check Box 1. Create the form using the Data Block and Layout Wizards 2. Open the item Property Palette, and change the Item Type value to Check Box 3. Modify the item properties 90
Important Check Box Properties 26 Value when Checked: data value of the item when the box is checked Label: description that appears next to the check box on the canvas Value when Unchecked: data value of the item when the box is checked Check Box Mapping of Other Values: check box status when form first opens, or when new blank record is added 91