B 14211
B 14211
B 14211
HIGHER EDUCATION
_________________________________________________________________________________________________________________ SunGard Higher Education 4 Country View Road Malvern, Pennsylvania 19355 United States of America (800) 522 - 4827 Customer Support Center website http://connect.sungardhe.com Distribution Services e-mail address [email protected] Other services In preparing and providing this publication, SunGard Higher Education is not rendering legal, accounting, or other similar professional services. SunGard Higher Education makes no claims that an institution's use of this publication or the software for which it is provided will insure compliance with applicable federal or state laws, rules, or regulations. Each organization should seek legal, accounting and other similar professional services from competent providers of the organization's own choosing. Trademark Without limitation, SunGard, the SunGard logo, Banner, Campus Pipeline, Luminis, PowerCAMPUS, Matrix, and Plus are trademarks or registered trademarks of SunGard Data Systems Inc. or its subsidiaries in the U.S. and other countries. Third-party names and marks referenced herein are trademarks or registered trademarks of their respective owners. Revision History Log Publication Date Summary 06/27/2008 Updated version to support new workbook design.
Notice of rights
Copyright SunGard Higher Education 2005-8. This document is proprietary and confidential information of SunGard Higher Education Inc. and is not to be copied, reproduced, lent, displayed or distributed, nor used for any purpose other than that for which it is specifically provided without the express written permission of SunGard Higher Education Inc.
Table of Contents
Introduction ............................................................................................................... 6 Introduction .................................................................................................................. 7 Introduction to Oracle Forms..................................................................................... 8 Overview of Oracle Forms .............................................................................................. 9 Forms Components.......................................................................................................10 Starting the Builder ......................................................................................................11 The Object Hierarchy....................................................................................................12 The Layout Editor .........................................................................................................13 The Property Palette.....................................................................................................14 Creating a Form Module ........................................................................................... 15 Creating a Form Module................................................................................................16 Naming a Form Module.................................................................................................17 How Forms Relate to Tables..........................................................................................18 Data Block Wizard: Navigating the Wizards ....................................................................19 Layout Wizard ..............................................................................................................25 Canvases .....................................................................................................................30 Content Canvas ............................................................................................................32 The Layout Editor ..................................................................................................... 33 Layout Editor Overview.................................................................................................34 Moving Objects ............................................................................................................35 Resizing Objects ...........................................................................................................36 Resizing the Canvas in the Layout Editor........................................................................37 Aligning Objects ...........................................................................................................38 Grouping Objects .........................................................................................................39 Boilerplate Text ............................................................................................................40 The Color Palette..........................................................................................................41 Windows .....................................................................................................................42 Compiling Your Form ....................................................................................................44 Module Access .............................................................................................................46 Running Your Form ......................................................................................................47 File Types ....................................................................................................................48 Forms Documentation...................................................................................................49 Customizing Data Blocks.......................................................................................... 50 Data Block Property Categories .....................................................................................51 Specifying the Default Navigation Sequence...................................................................58 Specifying the Default Navigation Sequence...................................................................58 Specifying the Navigation Style for a Data Block .............................................................59 Making Items Navigable and Enabled ............................................................................60 Creating a Data Block Manually .....................................................................................61 Joining Blocks ..............................................................................................................65
Text and Display Items ............................................................................................ 66 Creating a Text Item ....................................................................................................67 General Properties........................................................................................................68 Physical Properties .......................................................................................................69 Records Properties .......................................................................................................70 Visual Attribute Properties.............................................................................................71 Color Properties............................................................................................................72 Font Properties.............................................................................................................73 Prompt Properties.........................................................................................................74 Data Properties ............................................................................................................75 Initial Values ................................................................................................................76 Format Masks...............................................................................................................78 Navigation Properties....................................................................................................82 Database Properties .....................................................................................................83 Functional Properties ....................................................................................................84 Creating Multi-Line Text Items ......................................................................................85 Help Properties.............................................................................................................86 Display Items ...............................................................................................................87 Additional Items....................................................................................................... 89 Defining Check Boxes ...................................................................................................90 Converting a Text Item.................................................................................................92 Defining List Items .......................................................................................................93 Creating and Defining Radio Groups ..............................................................................97 Creating and Defining Buttons.....................................................................................101 Introduction to Triggers......................................................................................... 105 Triggers Overview ......................................................................................................106 PL/SQL Constructs......................................................................................................108 PL/SQL Editor.............................................................................................................110 Create a New Trigger .................................................................................................111 Trigger Definition and Scope .......................................................................................112 Trigger Properties.......................................................................................................117 Navigation with Triggers........................................................................................ 118 WHEN-NEW-Object-INSTANCE Triggers .......................................................................119 Pre- and Post-Triggers ................................................................................................121 WHEN-NEW-Object-INSTANCE Triggers .......................................................................124 Built-in Navigation Subprograms..................................................................................125 Validation Triggers ................................................................................................. 127 Validating Items During Data Entry..............................................................................128 When-Validate-Item ...................................................................................................129 Validating at the Record Level .....................................................................................130 Query Triggers........................................................................................................ 133 Query Processing .......................................................................................................134 PRE-QUERY................................................................................................................135 POST-QUERY .............................................................................................................136 Fire in Enter Query Mode ............................................................................................137 System Modes............................................................................................................138
Transaction Triggers .............................................................................................. 139 Transactions ..............................................................................................................140 Data Block-Level Transaction Triggers .........................................................................141 Form-Level Transactional Triggers ...............................................................................145 Creating Lists of Values and Editors ...................................................................... 147 What is a List of Values? .............................................................................................148 Creating an LOV Using the LOV Wizard ........................................................................149 Canvases, Part II.................................................................................................... 158 About Canvases..........................................................................................................159 Stacked Canvas ..........................................................................................................160 Toolbar Canvas ..........................................................................................................165 Tab Canvas ................................................................................................................167 Messages and Alerts............................................................................................... 171 What Kinds of Messages Are Automatically Displayed?..................................................172 Building Your Own Messages.......................................................................................173 Built-In Functions that Detect Success and Failure........................................................174 Triggers that Intercept Messages ................................................................................175 Alerts ...................................................................................................................176 Displaying the Alert ....................................................................................................178 Changing the Alert Message ........................................................................................179 Setting a Text Item During Runtime ............................................................................181 Obtaining Property Values From Items.........................................................................182 Sharing Objects and Code ...................................................................................... 184 Property Classes.........................................................................................................185 Creating Property Classes ...........................................................................................186 Object Groups ............................................................................................................189 Copying Vs. Subclassing..............................................................................................190 Multiple-Form Applications .................................................................................... 191 About Multiple-Form Applications.................................................................................192 OPEN_FORM ..............................................................................................................193 CALL_FORM Built-In ...................................................................................................195 NEW_FORM Built-In ...................................................................................................198 Global Variables .........................................................................................................200 DEFAULT_VALUE........................................................................................................201 Preparing to Move to Banner.......................................................................................202 Conversion.................................................................................................................204 Answer Guide ......................................................................................................... 205 Answer Guide.............................................................................................................206
Introduction
Course goal
This course provides an in-depth discussion of how to utilize Oracle Forms 6i.
Intended audience
Programmers with Oracle backgrounds who develop add-on modules for Banner or modify the baseline Banner forms.
Prerequisites
To complete this section, you should have completed the Education Practices computer-based training (CBT) tutorial Banner 6.x Fundamentals: Forms and Navigation, or have equivalent experience navigating in the Banner system completed the Introduction to Oracle training workbook completed the PL/SQL and Database Objects training workbook
SunGard 2004-2008
Page 6
Oracle Forms 6i
Introduction
Introduction
Oracle Forms is a development tool used for building client-server or web-based database applications that are portable to a variety of GUI and character mode platforms. All Banner forms have been written with this tool. This course provides an in-depth discussion of how to utilize Oracle Forms 6i.
Objectives
Upon completion of this course, attendees will be able to: Run an Oracle Forms 6i application Describe the layout editor Create and customize a default form Explain canvasses, windows, menus, modules, blocks, items properties, relations, and visual attributes Describe alerts, record groups, lists, and triggers Explain stored procedures and shared libraries
Topics
Oracle Forms 6i application Layout editor Default forms: creating and customizing Canvasses, windows, menus, modules, block properties, relations, and visual attributes Stored procedures, shared libraries, and images Banner design standards
SunGard 2004-2008
Page 7
Oracle Forms 6i
Introduction
Oracle Forms is part of Developer 2000, a suite of application development tools, which includes: Forms Procedure Builder Reports Graphics Procedure Builder Query Builder Schema Builder Translation Builder
The development tools have been designed to work together, and share many components. This course will focus on developing Forms, the most robust development tool within the suite.
Objectives
This section will examine the following: What is Forms? What can Forms do? Forms components Starting the Builder Examining the Builder components
SunGard 2004-2008
Page 8
Oracle Forms 6i
As a developer, Forms allows you to quickly create applications which can use a number of data sources allow code and objects to be easily copied are portable across platforms, including GUI and character-mode environments.
SunGard 2004-2008
Page 9
Oracle Forms 6i
Forms Components
Components
Component Forms Builder Forms Compiler Forms Runtime Description The development environment. Used to compile application files to create executable runfiles. Runtime engine that is used to run a generated Oracle Forms application.
Forms modules
Oracle Forms applications include four types of modules: Module type Forms Description Collections of objects and data, which allow the user to interact with the database. Data items are arranged into records. Collections of menu objects (main menu, pull-down menu, menu items) and menu command code. Collections of PL/SQL procedures, functions, and packages that can be called from other modules. Collections of form objects (items, data blocks, etc) that can be called from other modules.
SunGard 2004-2008
Page 10
Oracle Forms 6i
Enter the following command at the system prompt: ifbld60 [module] [userid/password] [parameters]
SunGard 2004-2008
Page 11
Oracle Forms 6i
Canvas
Area where you can "paint," or design, the layout of your form. A form can contain more than one canvas (known as a page in earlier Forms versions).
SunGard 2004-2008
Page 12
Oracle Forms 6i
SunGard 2004-2008
Page 13
Oracle Forms 6i
Components
The Toolbar contains buttons giving convenient access to functions relevant to setting properties: copy, paste, add, delete, class create and inherit. The Context bar identifies which object is currently having its properties displayed by the Property Palette. The Property List is a two-column display showing the property names in the left column and their current values in the right column. The properties are grouped by category. A + in front of a category name indicates that the category is expanded and that the properties within that category are all visible.
Comparing objects
Two or more objects can be compared by selecting all of the items you want to compare, then perusing the Property Palette. Properties having the same value in all selected objects will show the shared value, while properties that do not have the same value will display ***** for that property instead of a value. When you are showing the properties for multiple objects in a single palette, any property changed will be changed in all of the selected objects, overwriting whatever prior settings the objects had for that property.
SunGard 2004-2008
Page 14
Oracle Forms 6i
Introduction
This section is an introduction to creating and configuring basic form modules via wizards.
Objectives
This section will examine the following: Creating and naming form modules The Data Block Wizard The Layout Wizard Canvases
SunGard 2004-2008
Page 15
Oracle Forms 6i
SunGard 2004-2008
Page 16
Oracle Forms 6i
Exercise 1
Create a new form module called SWAIDEN. The naming convention follows Banner standards. SWAIDEN stands for: Student Custom object Application form Identification
SunGard 2004-2008
Page 17
Oracle Forms 6i
Data blocks
A data block is a logical container for interface items. All items, whether they come from a base table or not, must be in a data block.
SunGard 2004-2008
Page 18
Oracle Forms 6i
SunGard 2004-2008
Page 19
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 20
Oracle Forms 6i
SunGard 2004-2008
Page 21
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 22
Oracle Forms 6i
Exercise 2
In the new form module, create a data block based on the SWRIDEN table. Do not include the swriden_change_ind and swriden_activity_date columns
SunGard 2004-2008
Page 23
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 24
Oracle Forms 6i
Layout Wizard
Canvas Page Layout Step #1
Component Canvas Usage Select the canvas on which you want Oracle Forms to place the items that will be created in the data block. If New Canvas is selected, Oracle Forms automatically will create a new canvas. Type Tab Page Type of Canvas (Content, Stacked, Tab, Vertical Toolbar, or Horizontal Toolbar). Specific tab to place items Only used for tab canvas.
Screen image
SunGard 2004-2008
Page 25
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 26
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 27
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 28
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 29
Oracle Forms 6i
Canvases
Canvas and viewport
Think of the viewport as a rectangle positioned on the canvas. The area of the canvas that is within the viewport is what operators see displayed in the window at runtime. When the viewport is the same size as the canvas, all of the canvas is visible to the operator. When the viewport is smaller than the canvas, only the part of the canvas that is within the viewport is visible For a content or toolbar canvas, the viewport is defined by the window in which the canvas is displayed. Changing the size of the window at runtime (for example, by resizing it with the mouse) effectively changes the size of the viewport for that window's content canvas For a stacked or tab canvas, the size of the viewport can be specified at design time by setting the Viewport Width and Viewport Height properties
Canvas properties
For any type of canvas, you can set properties that specify the viewport's point of origin on the canvas; that is, to position the viewport rectangle at a specific location on its canvas. Moving the viewport, like resizing the viewport, changes the part of the canvas that operators see in the window at runtime. When a content canvas is larger than its viewport (that is, larger than its window), the window can be scrolled to change the position of the viewport on the canvas, thus making a different part of the canvas visible.
SunGard 2004-2008
Page 30
Oracle Forms 6i
4. Set the Window property to specify the window in which you want the canvas to be displayed. By default, new canvases are assigned to the first window listed under the Windows node in the Navigator. 5. To display the new canvas in the Layout Editor, double-click the canvases object icon in the Navigator.
SunGard 2004-2008
Page 31
Oracle Forms 6i
Content Canvas
Characteristics
Most canvases are content canvases A content canvas is the "base" view that occupies the entire content pane of the window in which it is displayed You must define at least one content canvas for each window you create More than one content canvas can be assigned to the same window at design time, but at runtime, only one of them at a time is displayed in the window
SunGard 2004-2008
Page 32
Oracle Forms 6i
Introduction
Although your forms are functional, they probably do not have the appearance you wish. You may want to move items around, add color, change labels, increase or decrease item widths, etc. Within this section, you will be introduced to some basic layout tools that will dramatically improve the look of your forms.
Objectives
This section will examine the following: Moving items with the mouse Resizing objects Resizing the canvas Aligning objects Grouping objects Creating and modifying boilerplate text Adding colors and borders
SunGard 2004-2008
Page 33
Oracle Forms 6i
You can open more than one Layout Editor at the same time, and can copy and paste objects between Layout Editors as needed.
Restrictions
You cannot clear, cut, copy, duplicate, or export the following objects in the Layout Editor: the canvas object (when the ViewShow Canvas option is On) the view rectangle (when the ViewShow View option is On) a data block scroll bar
SunGard 2004-2008
Page 34
Oracle Forms 6i
Moving Objects
Moving an object or objects
To move an object, position the Select tool over it, then click and drag the object to the desired location. To move more than one object at a time, select the objects, then click and drag any selected object to move all of the objects in the selection.
Constraining a move
To constrain a move to be vertical, diagonal, or horizontal, hold down [Constrain] (Shift on most platforms) while dragging the selected object.
Note
If you have used the Layout wizard and have created a frame for a data block, the frame will keep the items in the original order regardless of how you move them.
SunGard 2004-2008
Page 35
Oracle Forms 6i
Resizing Objects
Resizing objects
You can resize objects with the mouse, or by specifying precise dimensions in the Size Objects dialog. To resize an object: 1. Select the object you want to resize. 2. Resize the object by dragging one of its selection handles. To constrain a resize operation, hold down the Shift key while resizing the selected object. For example, Shift-dragging constrains a rectangle to a square, and an ellipse to a circle. Or: 3. Select ArrangeSize Objects to invoke the Size Objects dialog, then set Width and/or Height to Custom, and enter the desired setting. Once you have specified the size of an object, you can apply the same dimensions to other selected objects with the ArrangeRepeat Sizing command.
SunGard 2004-2008
Page 36
Oracle Forms 6i
SunGard 2004-2008
Page 37
Oracle Forms 6i
Aligning Objects
Aligning objects
1. Select the objects you wish to align. 2. Select ArrangeAlign Objects to display the Alignment Settings dialog, or use the icons on the horizontal toolbar. 3. Specify how you want the selected objects to be aligned. A single object can be aligned to the grid. Multiple selected objects can be aligned to the grid or to each other. You can specify horizontal and/or vertical alignment options. 4. Click OK to accept the settings and dismiss the dialog.
SunGard 2004-2008
Page 38
Oracle Forms 6i
Grouping Objects
Groups of objects
You can select multiple objects and create a group. The group can then be manipulated as a single object. For example, you might want to group several objects together and then move the group as a unit, without changing the relative positions of the objects in the group.
Grouping objects
To group objects: 1. Select two or more objects. 2. Select ArrangeGroup. The new group is automatically selected, and you can manipulate it as you would a single object.
Ungrouping objects
To ungroup objects: 1. Select the group. 2. Choose ArrangeUngroup.
SunGard 2004-2008
Page 39
Oracle Forms 6i
Boilerplate Text
Boilerplate graphics
Boilerplate graphics are the lines, circles, text, and images that you draw or import onto a canvas-view. Boilerplate graphics are associated with the canvas-view on which you place them; deleting a canvas-view deletes all of its boilerplate objects. Unlike items, boilerplate graphics are not named objects. Boilerplate objects do not appear in the Object Navigator and their properties are not displayed in the Properties window.
2. Click the boilerplate text object you want to edit. 3. Edit the text as desired. 4. Click in the workspace anywhere outside the text object's bounding box to cancel text mode.
SunGard 2004-2008
Page 40
Oracle Forms 6i
SunGard 2004-2008
Page 41
Oracle Forms 6i
Windows
Windows
A window is just a container for all the GUI objects that make up the form application. The window is a frame for the application. A form can include any number of windows. Every new form automatically includes a default window named WINDOW1.
3. Double-click the Window icon to the left of the text name to display its property palette. 4. For each window you create, you must also create at least one content canvas. You can associate the canvas with the window by setting the Primary Canvas Window property.
Display Properties
Property X Position Y Position Width Height Title Usage X coordinate of the window Y coordinate of the window Width of the window Height of the window Window title in title bar
SunGard 2004-2008
Page 42
Oracle Forms 6i
Functional Properties
Property Primary Canvas Show Vertical Toolbar Show Horizontal Toolbar Modal Window Style Usage The name of the canvas to display in the window when invoked programmatically. Determines the presence of a vertical toolbar in a window. Determines the presence of a horizontal toolbar in a window. Determines whether the window is modal or modeless. Specifies whether the window is a Document window or a Dialog window. Document Style windows are fixed and must remain inside the application frame. Dialog Style windows are free and can be moved outside the application frame. Specifies the icon filename used to represent the minimized window. Whether a modeless window closes on exit.
SunGard 2004-2008
Page 43
Oracle Forms 6i
SunGard 2004-2008
Page 44
Oracle Forms 6i
Compiler
The Forms Compiler is the best compiler to use for Banner Forms.
Screen
SunGard 2004-2008
Page 45
Oracle Forms 6i
Module Access
Default save settings
You have the option to save forms, menus, and libraries to the database, rather than saving them to a file. To change the default setting from File to Database, select ToolsPreferences (see below). The modules will be saved to Forms tables (whose filenames begin with FRM45). Because of performance issues, and the fact that database space is usually more precious than file space, all of Banner's modules are stored as files.
SunGard 2004-2008
Page 46
Oracle Forms 6i
SunGard 2004-2008
Page 47
Oracle Forms 6i
File Types
File types
Form, menu, and library modules that you create in the Builder are stored in binary format can be saved to files or to the database portable across platforms.
When you generate a binary module, Oracle Forms creates a platform-specific runfile. Module Form Menu PL/SQLLibrary Object Library Binary (Design) .FMB .MMB .PLL .OLB Text .FMT .MMT .PLD .OLT Executable Runfile .FMX .MMX .PLX
Text versions
Text versions of the binary files can be created by selecting FileAdministrationConvert. Choose the module type (form, menu, library), the module name, and the conversion direction (binary to text, or text to binary). The text version can then be converted back, if necessary.
SunGard 2004-2008
Page 48
Oracle Forms 6i
Forms Documentation
Documentation
Although the text versions of the modules can be opened in a word processor and examined, the text version of a module is not intended for documentation purposes. Instead, open the desired form up in the Object Navigator and select FileAdministrationObject List Report. A .txt version of the form will be created in the same directory as the form. The Forms documentation cannot be converted into an .fmb.
SunGard 2004-2008
Page 49
Oracle Forms 6i
Introduction
Data block properties may need to be modified after the data block has been created. Within this section, we will take a look at the many data block properties you can set to enhance the functionality of your form.
Objectives
This section will examine the following: Data block properties Setting properties on multiple objects
SunGard 2004-2008
Page 50
Oracle Forms 6i
General properties
Property Name Subclass Information Comments Description Name of the data block. Specifies the class that has passed its properties to the data block. Describes the data block in detail.
SunGard 2004-2008
Page 51
Oracle Forms 6i
Navigation Properties
Property Navigation Style Next/Previous Navigation Data Block Description Once the user has navigated to the last item, where should the cursor go? Same Record, Next Record, Next Block. Usually, the next or previous data block is determined by the order of the data blocks within the Object Navigator, which is also the order that the form posts changes to the database. If this needs to be overridden, then specify the name of the data block within these properties.
Exercise 4
In the ID data block, allow the user to automatically navigate to the next record when tabbing, by modifying the Navigation Style on the data block level.
SunGard 2004-2008
Page 52
Oracle Forms 6i
Records Properties
Property Current Record Visual Attribute Group Query Array Size Number of Records Buffered Number of Records Displayed Query All Records Record Orientation Single Record Description Allows you to associate a visual attribute with the current record. Used to highlight the current record. Specifies the maximum number of records that Form Builder should fetch from the database at one time. Specifies the minimum number of records buffered in memory during a query in the data block. Number of records to be displayed for the data block on the canvas. Specifies whether all the records matching the query criteria should be fetched into the data block when a query is executed. Whether the records are oriented vertically or horizontally. The default is vertical. Specifies that the control data block always should contain one record. Note: This differs from the number of records displayed in a data block.
SunGard 2004-2008
Page 53
Oracle Forms 6i
Database Properties
Property Database Data Block Enforce Primary Key Delete Allowed, Insert Allowed, Update Allowed, Query Allowed Query Data Source Type Query Data Source Name Query Data Source Columns WHERE Clause/ ORDER BY Clause Optimizer Hint Description Specifies that the data block is based on any of the following data source types: Table, Procedure, Transactional Trigger, or Sub-
Query.
Indicates that any record inserted or updated in the data block must have a unique key in order to avoid committing duplicate rows to the data block's base table. Specifies whether records can be deleted, inserted, updated, or queried within the data block. The default for these properties is Yes. Specifies the query data source type for the data block. A query data source type can be a Table, Procedure, Transactional Trigger, or FROM clause query. Specifies the name of the data block's query data source. Specifies the names and datatypes of the columns associated with the data block's query data source. Only used when Query Data Source Type property is set to Table, Sub-query, or Procedure. These clauses are automatically appended to the SELECT statement that Oracle Forms constructs and issues whenever the operator or the application executes a query in the data block. Specifies a hint string that Oracle Forms passes on to the RDBMS optimizer when constructing queries. Using the optimizer can improve the performance of database transactions. When queried records have been marked as updates, specifies that only columns whose values were actually changed should be included in the SQL UPDATE statement that is sent to the database during a COMMIT. By default, Update Changed Columns Only is set to No, and all columns are included in the UPDATE statement.
SunGard 2004-2008
Page 54
Oracle Forms 6i
Exercise 5
In the SWRIDEN block, increase the number of records displayed to 5
Exercise 6
Ensure that the records retrieved in the SWRIDEN data block are current (the swriden_change_ind is NULL) by adding a WHERE clause.
Exercise 7
Sort the records in the SWRIDEN data block by last name.
SunGard 2004-2008
Page 55
Oracle Forms 6i
Exercise 8
Make sure the user is unable to insert, update, or delete records in the Identification data block.
SunGard 2004-2008
Page 56
Oracle Forms 6i
Database Properties
Property Enforce Column Security Description Specifies when Oracle Forms should enforce update privileges on a column-by-column basis for the data block's base table. If an operator does not have update privileges on a particular column in the base table, Oracle Forms makes the corresponding item nonupdateable for this operator only, by turning off the Update Allowed item property at form startup. Provides the option to abort a query when the elapsed time of the query exceeds the value of this property. Specifies the number of records fetched when running a query before the query is aborted. Default settings are appropriate for an Oracle database, but may need to be modified for other database types.
Maximum Query Time Maximum Records Fetched Key Mode/Locking Mode Triggers
Scrollbar Properties
Property Show Scroll Bar Description Specifies whether the scroll bar will be associated with the data block.
SunGard 2004-2008
Page 57
Oracle Forms 6i
SunGard 2004-2008
Page 58
Oracle Forms 6i
Change Record
SunGard 2004-2008
Page 59
Oracle Forms 6i
No
Yes
No
No
SunGard 2004-2008
Page 60
Oracle Forms 6i
Process
1. Highlight Data Blocks. 2. Click the icon.
4. BLOCK# appears. Rename the block SWRADDR. 5. Open the property palette. 6. Set Query Data Source Name to SWRADDR. 7. Highlight items. 8. Click the icon.
9. ITEM# appears. Go to the property palette and rename it to swraddr_atyp_code. 10. Set column name to swraddr_ atyp_code.
SunGard 2004-2008
Page 61
Oracle Forms 6i
11. Set canvas to canvas1. 12. Repeat the above steps so that your layout editor looks like this and includes the following columns: swraddr_phone_area swraddr_phone_number swraddr_street_line1 swraddr_city swraddr_stat_code swraddr_zip
SunGard 2004-2008
Page 62
Oracle Forms 6i
Canvas 1
SunGard 2004-2008
Page 63
Oracle Forms 6i
Exercise 9
In the SWAIDEN form, create a data block based on the SWBPERS table. Include all columns Display the records on a new canvas called Canvas2
SWAIDEN Canvas 2
SunGard 2004-2008
Page 64
Oracle Forms 6i
Joining Blocks
Specifying a join condition
The join specified is similar to an SQL join, except the specification is Data_Block.item = Data_Block.item, rather than Table.column = Table.column. Join the address block and the person block together. The database column must be on the right and the current item (prefixed by :) is on the left.
Exercise 10
Join both the swraddr and swbpers blocks to the swriden pidm.
SunGard 2004-2008
Page 65
Oracle Forms 6i
Introduction
All items, just like data blocks, have individual property sheets which allow properties to be changed to enhance the functionality of the form. In this section, we will focus on text item properties.
Objectives
This section will examine the following: Create a new text item Examine and modify text item properties Create a display item
SunGard 2004-2008
Page 66
Oracle Forms 6i
3. Double-click the Text icon to the left of the text name to display its property sheet.
2. Click an area on the canvas to create the text item. 3. Double-click the text item to display its property sheet.
Exercise 11
In the SPRIDEN data block, set the canvas to null within the pidm item's property palette.
SunGard 2004-2008
Page 67
Oracle Forms 6i
General Properties
General properties
Property Item Type Description Specifies the type of item.
SunGard 2004-2008
Page 68
Oracle Forms 6i
Physical Properties
Physical Properties
Property Visible Canvas Tab Page X Position Description Determines whether an item that is assigned to a canvas is shown or hidden at runtime. Specifies the canvas on which you want the item to be displayed. Specifies the tab page on which the item is located. Tab Canvases only. Specifies the position of the item's upper left corner relative to the upper left corner of the item's canvas. The values you specify are interpreted in the current form coordinate units (character cells, centimeters, inches, pixels, or points), as specified by the Coordinate System form property. Specifies the position of the item's upper left corner relative to the upper left corner of the item's canvas. The values you specify are interpreted in the current form coordinate units (character cells, centimeters, inches, pixels, or points), as specified by the Coordinate System form property. Sets the width of the item. Sets the height of the item. Specifies the appearance of the object border: either RAISED, LOWERED, INSET, OUTSET, PLAIN, or NONE. Specifies that the item is to be displayed as a rendered object when it does not have focus. Specifies that a vertical scroll bar is to appear on the side of a canvas or window.
Y Position
SunGard 2004-2008
Page 69
Oracle Forms 6i
Records Properties
Records Properties
Property Current Record Visual Attribute Group Distance Between Records Number of Items Displayed Description Specifies the named visual attribute used when an item is part of the current record. Specifies the amount of space between instances of the item when the item is in a multi-record data block. Specifies the number of item instances displayed for the item when the item is in a multi-record data block.
SunGard 2004-2008
Page 70
Oracle Forms 6i
SunGard 2004-2008
Page 71
Oracle Forms 6i
Color Properties
Color Properties
Property Foreground Color Background Color Fill Pattern Description Specifies the foreground color for the item. Specifies the background color for the item. Specifies the pattern for the item.
SunGard 2004-2008
Page 72
Oracle Forms 6i
Font Properties
Font Properties
Property Font Name Font Size, Font Style, Font Spacing, Font Weight Description Specifies the name of the font to be used for the item. Specifies attributes for the font chosen.
SunGard 2004-2008
Page 73
Oracle Forms 6i
Prompt Properties
Prompt Properties
Property Prompt Description Specifies the text label that displays for an item.
SunGard 2004-2008
Page 74
Oracle Forms 6i
Data Properties
Data Properties
Property Data Type Description Specifies what kinds of values Oracle Forms allows as input and how Oracle Forms displays those values (Examples: NUMBER, CHAR). Specifies the maximum length of the data value that can be stored in the item. When set to No, Fixed Length specifies that the item should be considered valid only when it contains the maximum number of characters allowed. Specifies the default value that Oracle Forms should assign to the item whenever a record is created. When a new record is being entered, specifies that the item is invalid when its value is NULL. Specifies the display format and input accepted for data in text items. Determines the maximum value or minimum value, inclusive, that Oracle Forms allows in the text item. Specifies the source of the value that Oracle Forms uses to populate the item. When you define a master-detail relation, Oracle Forms sets this property automatically on the foreign key item(s) in the detail data block. Specifies the name of the item from which the current item should derive its value. Setting this property synchronizes the values of the two items, so that they effectively mirror each other. Used for items within the same data block.
Initial Value Required Format Mask Lowest / Highest Allowed Value Copy Value From Item
SunGard 2004-2008
Page 75
Oracle Forms 6i
Initial Values
Initial values
You can specify initial values for items by setting the Initial Value item property. The value you specify must be compatible with the item's data type. For example, the initial value for a text item having a data type of DATE must be a value that can be displayed in a valid date format. The initial value can be any of the following: Raw Value 100, 'Y' System Variables Operating system current date/time: $$DATE$$ $$DATETIME$$ $$TIME$$ Current database date/time: $$DBDATE$$ $$DBDATETIME$$ $$DBTIME$$ Form Item Value :Address.atyp_code Global Variable :GLOBAL.pidm Form Parameter :PARAMETER.pidm Sequence :SEQUENCE.pidm_sequence.NEXTVAL DD-MON-YY DD-MON-YYYY hh:mi[:ss] Hh:mi[:ss] DD-MON-YY DD-MON-YYYY hh:mi[:ss] Hh:mi[:ss]
SunGard 2004-2008
Page 76
Oracle Forms 6i
Exercise 12
In both the Address and Person data blocks: Alter the activity dates so that it initializes to the current database date for a new record. Try using an intersection to set the property for both items at the same time For both data blocks, do not allow the activity dates to be updated or inserted by the user Set the bubble help to Activity Date Set the format mask so that the date appears like the following: 01-JAN-1998 Remember to alter the maximum length to allocate for the increase in characters
SunGard 2004-2008
Page 77
Oracle Forms 6i
Format Masks
Format masks for number values
Symbol 9 0 $ B MI PR , (comma) . (decimal) Description Represents one numeric character. The number of 9's determines how many digits the text item can display. Displays leading zeroes when present. Prefix number with a dollar sign. Displays preceding zeroes as blank spaces. Displays - after a negative value. Displays negative values in <angle brackets>. Displays a comma in this position as required. Displays a decimal in this position.
SunGard 2004-2008
Page 78
Oracle Forms 6i
SunGard 2004-2008
Page 79
Oracle Forms 6i
Exercise 13
In the Person data block, set the format mask for swbpers_birth_date so that it appears like the following: 01-JAN-1998. Set the bubble help to Birth Date.
SunGard 2004-2008
Page 80
Oracle Forms 6i
Exercise 14
In the Person data block, set the format mask for SSN so that it appears like the following at runtime: 123-45-6789. Set Fixed Length to Yes.
Exercise 15
In the Address data block, set the format mask for the phone number so that it appears like the following at runtime: 555-1212. Set Fixed Length to Yes.
SunGard 2004-2008
Page 81
Oracle Forms 6i
Navigation Properties
Navigation properties
Property Keyboard Navigable Next Navigation Item Description Determines whether the operator or the application can place the input focus in the item during default navigation. Specifies the name of the item that is defined as the "next navigation item" with respect to this current item. By default, the next navigation item is the item with the next higher sequence as indicated by the order of items in the Object Navigator. However, you can set this property to redefine the "next item" for navigation purposes. Previous Navigation Item Specifies the name of the item that is defined as the "previous navigation item" with respect to this current item.
SunGard 2004-2008
Page 82
Oracle Forms 6i
Database Properties
Database properties
Property Database Item Column Name Primary Key Description Determines if the item value is stored in the data block base table. Specifies that an item corresponds to a column in the table associated with the data block. Set automatically for Oracle. Indicates that the item is a base table item in a base table data block and that it corresponds to a primary key column in the base table. Insert Allowed Query Only Query Allowed Query Length Case Insensitive Query Update Allowed Update Only if Null Lock Record Determines whether the item allows values to be inserted. Specifies that the item can be queried but not included in an INSERT or an UPDATE statement. Determines whether the item can be queried. Determines the maximum length of a query expression for the item. Should be at least as long as the Maximum Length value. Determines whether case should be a factor when queries are performed. Determines whether the item can be updated. Determines whether the item should only be updated if the value is null for the record. Determines whether the record is locked when the item is changed; this property is only relevant to non-base table items.
SunGard 2004-2008
Page 83
Oracle Forms 6i
Functional Properties
Functional properties
Property Enabled Justification Multi-Line Wrap Style Description Determines whether operators can navigate to an item and manipulate it with the mouse. Determines the text justification of the value within the item. Determines whether the text item is a single-line or multi-line editing region. Specifies how text is displayed when a line of text exceeds the width of a text item or editor window, either None, Character, or Word. Automatically converts the case of the user's input to either Upper, Lower, or Mixed. Hides characters that the operator types into the text item. This setting is typically used for password protection. Specifies that the cursor position be the same upon re-entering the text item as when last exited. Moves the cursor to the next navigable item when adding or changing data in the last character of the current item. The last character is defined by the Maximum Length property. Used in conjunction with the Fixed Length property. Specifies the popup menu to display with the item.
Popup Menu
SunGard 2004-2008
Page 84
Oracle Forms 6i
SunGard 2004-2008
Page 85
Oracle Forms 6i
Help Properties
Help properties
Property Hint Automatic Hint Tooltip Tooltip Visual Attribute Group Description The message to be displayed in the console for the item. During runtime, select HelpHelp to display the hint. Determines if the help text specified by the item property, Hint, is displayed automatically when the cursor enters the item. Specifies the help text that should appear in a small box beneath the item when the mouse enters the item. (Bubble Help) Specifies the named visual attribute that should be applied to the tooltip at runtime.
SunGard 2004-2008
Page 86
Oracle Forms 6i
Display Items
Display items
Display items are similar to text items with the exception that display items only store and display fetched or assigned values. Operators cannot navigate to display items or edit display item values.
2. Click the canvas to place the display item on the canvas. 3. Resize the display item if needed. 4. If needed, change the data block to which the display item is assigned using the data block pop-list. 5. Double-click the check box to view the Property Sheet.
SunGard 2004-2008
Page 87
Oracle Forms 6i
Exercise 16
In the Address data block, create a new display item named atyp_desc. Ensure that atyp_desc is not a base table item Assign the item to Canvas1 Set the bubble help to Address Description The display item will be populated by a trigger in a later exercise On the canvas, place it to the right of the swraddr_atyp_code
SunGard 2004-2008
Page 88
Oracle Forms 6i
Additional Items
Introduction
Although text items alone would allow the user to manipulate data in the database, a form can be enhanced by adding GUI items, such as check boxes, radio buttons, list items, calculated items, hierarchical tree items, and push buttons.
Objectives
This section will examine the following: Creating checkboxes Creating radio buttons Creating list items Creating calculated items Creating hierarchical tree items Creating push buttons
SunGard 2004-2008
Page 89
Oracle Forms 6i
SunGard 2004-2008
Page 90
Oracle Forms 6i
2. Click the canvas to place the checkbox on the canvas. 3. Resize the check box if needed. 4. If needed, change the data block to which the check box is assigned using the data block pop-list. 5. Double-click the check box to view the Property Palette.
Label Mouse Navigate Value When Checked Value When Unchecked Check Box Mapping of Other Values
SunGard 2004-2008
Page 91
Oracle Forms 6i
Exercise 17
In the Person data block, convert the swbpers_confid_ind text item to a check box. Set the checked state to represent the base table value of Y and the unchecked state to represent N Ensure that new records are automatically assigned the value N Allow only those records with swbpers_confid_ind values of Y or N to display Resize the checkbox appropriately
SunGard 2004-2008
Page 92
Oracle Forms 6i
Text List
Combo Box
SunGard 2004-2008
Page 93
Oracle Forms 6i
SunGard 2004-2008
Page 94
Oracle Forms 6i
2. Click the canvas to place the list item on the canvas. 3. Resize the list item if necessary. 4. If needed, change the data block to which the list item is assigned using the data block poplist. 5. Double-click the list item to display the Property Palette. 6. Specify the display style for the list by setting the List Style property to Poplist, Text List, or Combo Box. 7. Double-click the List Elements property to display the List Items Elements dialog, then enter the List Elements exactly as you want them to appear in the list item at runtime. 8. Associate a value with each List Element by entering the desired value in the List Item Value field, then choose OK.
SunGard 2004-2008
Page 95
Oracle Forms 6i
Exercise 18
In the Person data block, convert the swbpers_mrtl_code text item to a pop-list list item. Add list elements of Single, Married, Widowed, and Divorced to represent database values of S, M, W, and D Display any other values as Single Ensure that new records display the default value Single Resize the list item to see your choices at runtime
SunGard 2004-2008
Page 96
Oracle Forms 6i
Mouse Navigate
SunGard 2004-2008
Page 97
Oracle Forms 6i
SunGard 2004-2008
Page 98
Oracle Forms 6i
Exercise 19
In the Person data block, convert the swbpers_sex text item into a radio group. Add radio buttons for Male, Female and Other to represent the database values of M, F and O Define access keys of M for male, F for female, and O for Other Define a default value of F for all new records
SunGard 2004-2008
Page 99
Oracle Forms 6i
2. Click the canvas to place the radio button on the canvas. 3. If a radio group exists, you will be asked if the radio button you are creating should belong to an existing radio group. If none exists, it will create a radio group for you. 4. Resize the radio button if necessary. 5. If needed, change the data block to which the radio button is assigned using the data block poplist. 6. Double-click the radio button to display the Property Palette. 7. In the property palette, create a label for the radio button by entering the desired text in the Label property field. 8. Enter a value for the currently selected radio button in the Radio Button Value property field. The values you assign to each radio button must be compatible with the datatype for the radio group. 9. Specify the display properties of the currently selected radio button. 10. Specify how you want the radio group to handle fetched or assigned values that are not one of the values associated with a specific radio button. To do so, set the Mapping of Other Values property for the radio group.
SunGard 2004-2008
Page 100
Oracle Forms 6i
2. Click the canvas to place the button on the canvas. 3. Resize the button if necessary. 4. If needed, change the data block to which the button is assigned using the data block poplist. 5. Double-click the button to view the Property Palette.
SunGard 2004-2008
Page 101
Oracle Forms 6i
Iconic buttons
To make a button an iconic button: 1. In the Navigator, select the desired button. 2. In the Property Palette, set the Iconic property to Yes. 3. Enter the name of the icon in the Icon Filename property field. Do not include the icon file extension.
Button Properties
Property Access Key Usage Specifies the character that will be the access key, allowing the operator to select or execute an item by pressing a key combination, such as Alt-C. Specifies the text label that displays for a button. Specifies whether Oracle Forms should perform navigation to the button when the operator activates the item with a mouse. Specifies whether this button is the default one for the data block. Specifies whether a button is to be an iconic button. Specifies the name of the icon file. Do not include the icon file extension.
SunGard 2004-2008
Page 102
Oracle Forms 6i
GO_BLOCK
Navigates to an indicated data block. If the target data block is non-enterable, an error occurs.
Syntax:
go_block('block_name');
SunGard 2004-2008
Page 103
Oracle Forms 6i
Exercise 20
Create a control data block. Create three non-database items and convert all of them to push buttons: Button 1 Label: Person Add trigger when-button-pressed for navigation to the Person block Place on canvas1
Button 2 Label: Return Add trigger when-button-pressed for navigation to the ID block Place on canvas2
Button 3 Label: Exit Add trigger when-button-pressed and enter exit_form; Place on canvas1
SunGard 2004-2008
Page 104
Oracle Forms 6i
Introduction to Triggers
Introduction
Triggers are data blocks of code you write to add functionality to a default application. You can create a basic application without writing triggers, using only Oracle Forms' default processing to retrieve, add, delete, and change database records. However, you will usually need to write triggers to customize your application.
Objectives
This section will examine the following: Purpose and types of triggers Rules for writing triggers
SunGard 2004-2008
Page 105
Oracle Forms 6i
Triggers Overview
What are triggers?
Triggers are data blocks of code you write to customize your application. The names of triggers correspond to runtime events, which in turn tell Oracle when the code should be executed.
SunGard 2004-2008
Page 106
Oracle Forms 6i
Groups of triggers
Group When-triggers On-triggers Pre- and Posttriggers Key-trigger Function Execute in addition to default processing Replace default processing Add processing before or after an event Change default processing assigned to a specific key
SunGard 2004-2008
Page 107
Oracle Forms 6i
PL/SQL Constructs
PL/SQL data blocks
The text of an Oracle Forms trigger is an anonymous PL/SQL data block. A data block can consist of three sections: a declaration section for variables, constants, cursors, and exceptions (optional) executable statements (required) exception handlers (optional)
PL/SQL Syntax
DECLARE -- declarative statements (optional) BEGIN -- executable statements (required) EXCEPTION -- exception handlers (optional) END;
SunGard 2004-2008
Page 108
Oracle Forms 6i
Note
Transactional statements, such as COMMIT, SAVEPOINT, and ROLLBACK cannot be included directly in trigger code. Built-in subprograms can be called instead, which will be discussed later.
SunGard 2004-2008
Page 109
Oracle Forms 6i
PL/SQL Editor
PL/SQL Editor
The PL/SQL Editor is where you enter and compile code objects. Code objects in Oracle Forms include event triggers, subprograms (functions and procedures), menu item commands, menu startup code, and packages.
SunGard 2004-2008
Page 110
Oracle Forms 6i
SunGard 2004-2008
Page 111
Oracle Forms 6i
Trigger scope
A trigger's definition level determines the trigger's scope. The scope of a trigger is its domain within the Oracle Forms object hierarchy, which determines where an event must occur for the trigger to respond to it. A data block-level trigger fires if the trigger event occurs within that data block, but it does not fire if the same event occurs in some other data block.
Example
If you wanted a trigger to fire when Button1 in your form was pressed, you have the option to define the trigger at the item, data block, and form level. Level Item Level Data Block Level Form Level Result Fires only when Button1 is pressed. Fires when any button in the data block is pressed. Fires when any button in the form is pressed.
By default, only the trigger that is most specific to the cursor's current location will fire. Let's expand on the example above.
SunGard 2004-2008
Page 112
Oracle Forms 6i
Diagram 1
Within form MY_FORM, three WHEN-BUTTON-PRESSED triggers are placed.
SunGard 2004-2008
Page 113
Oracle Forms 6i
Diagram 2
Instance One: Button 1 is pressed. The trigger defined at the item level is fired (C).
SunGard 2004-2008
Page 114
Oracle Forms 6i
Diagram 3
Instance Two: Button 2 is pressed. Because no trigger is defined at the item level, Oracle Forms looks next at the Data block level. Since a WHEN-BUTTON-PRESSED trigger is defined at the data block level (B), it is fired.
SunGard 2004-2008
Page 115
Oracle Forms 6i
Diagram 4
Instance Three: User presses Button 3. Forms looks for a trigger at the item level. Since none exists, it looks at the data block level. Since that does not exist, the WHENBUTTON-PRESSED trigger is fired at the form level (A).
SunGard 2004-2008
Page 116
Oracle Forms 6i
Trigger Properties
Execution Style
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: Setting Override Description 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. The default. Specifies that the current trigger fire before firing the same trigger at the next-higher scope. This is known as "fire before parent" behavior. Specifies that the current trigger fire after firing the same trigger at the next-higher scope. This is known as "fire after parent" behavior.
Before
After
If a trigger is not failed, then processing continues. In the example above, if the RAISE FORM_TRIGGER_FAILURE was omitted, the user would receive the message but would be allowed to leave the item.
SunGard 2004-2008
Page 117
Oracle Forms 6i
Introduction
As a user, you have been able to navigate around your form using the mouse, function keys, and the pull-down menu. Because a GUI environment offers so many ways of leaving or entering items, you may want to perform checks before allowing movement. In addition, you may want to automate more for the user, navigating to items for them programmatically.
Objectives
This section will examine the following: Default navigation sequence Controlling navigation through triggers Built-in navigation subprograms
SunGard 2004-2008
Page 118
Oracle Forms 6i
WHEN-NEW-Object-INSTANCE Triggers
Trigger WHEN-NEW-ITEM-INSTANCE WHEN-NEW-RECORD-INSTANCE WHEN-NEW-BLOCK-INSTANCE WHEN-NEW-FORM-INSTANCE Description Fires after the input focus successfully moves to an item. Fires after the input focus successfully moves to a record. Fires after the input focus successfully moves to a data block. Fires after the input focus successfully moves to a form.
Exercise 21
At the form level, create a trigger to immediately execute a query.
At both block levels for SWRADDR and SWBPERS when the block is entered also, execute a query.
SunGard 2004-2008
Page 119
Oracle Forms 6i
Exercise 22
When navigating to the next record in the ID block, get the records in the address block to change as well.
SunGard 2004-2008
Page 120
Oracle Forms 6i
Fires during the Leave the Form process, when a form is exited. Uses: To clean up the form before exiting, such as global variables that the form no longer requires To display a message to the operator upon form exit
PRE-BLOCK
Fires during the Enter the Data Block process, during navigation from one data block to another. Uses: Allow or disallow access to a data block Set variable values
POST-BLOCK
Fires during the Leave the Data Block process. Uses: Validate the data block's current record To test a condition and prevent the user from leaving a data block based on that condition
SunGard 2004-2008
Page 121
Oracle Forms 6i
PRE-RECORD
Fires during the Enter the Record process, during navigation to a different record. Uses: Keep a running total
POSTRECORD
Fires during the Leave the Record process. Specifically, the Post-Record trigger fires whenever the operator or the application moves the input focus from one record to another. Uses: Perform an action whenever the operator or the application moves the input focus from one record to another
PRE-TEXTITEM
Fires during the Enter the Item process, during navigation from an item to a text item. Uses: Derive a complex default value, based on other items previously entered into the same record Record the current value of the text item for future reference, and store that value in a global variable or form parameter
POST-TEXTITEM
Fires during the Leave the Item process for a text item. Specifically, this trigger fires when the input focus moves from a text item to any other item. Uses: Calculate or change item values
SunGard 2004-2008
Page 122
Oracle Forms 6i
Exercise 23
Write a PRE-FORM trigger in SWAIDEN, which checks the username. If the name does not match your username, fail the trigger and display a message. Use the built-in subprogram GET_APPLICATION_PROPERTY. Attempt to run your form under a different training account. What occurred?
SunGard 2004-2008
Page 123
Oracle Forms 6i
WHEN-NEW-Object-INSTANCE Triggers
Trigger WHEN-NEW-ITEM-INSTANCE WHEN-NEW-RECORD-INSTANCE WHEN-NEW-BLOCK-INSTANCE WHEN-NEW-FORM-INSTANCE Description Fires after the input focus successfully moves to an item. Fires after the input focus successfully moves to a record. Fires after the input focus successfully moves to a data block. Fires after the input focus successfully moves to a form.
SunGard 2004-2008
Page 124
Oracle Forms 6i
SunGard 2004-2008
Page 125
PREVIOUS_RECORD PREVIOUS_ITEM
Navigates to the first enabled and navigable item in the record with the next lower sequence number than the current record. Navigates to the navigable item with the next lower sequence number than the current item. If there is no such item, PREVIOUS_ITEM navigates to the navigable item with the highest sequence number.
Example
/* WHEN-BUTTON-PRESSED-TRIGGER Navigate to Data Block A */ GO_BLOCK('BLOCKA'); IF NOT FORM_SUCCESS THEN MESSAGE('Could not navigate to Data Block A'); RAISE FORM_TRIGGER_FAILURE; END IF;
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.
CURSOR_POSITION
SunGard 2004-2008
Page 126
Oracle Forms 6i
Validation Triggers
Introduction
Validation triggers fire when Oracle Forms validates data in an item or record. Oracle Forms performs validation checks during navigation that occur in response to operator input, programmatic control, or default processing, such as commit operation.
Objectives
This section will examine the following: When does forms validate? What are the types of validation triggers?
SunGard 2004-2008
Page 127
Oracle Forms 6i
When you need to add application-specific validation, you can write a When-Validate-Item trigger. This will fire after the standard checks listed above.
SunGard 2004-2008
Page 128
Oracle Forms 6i
When-Validate-Item
Introductions
The WHEN-VALIDATE-ITEM trigger is used for two main purposes: validating an item populating non-base table items
Populate an item
To populate an item with values from another table: 1. Create an item of the desired type in the appropriate base table data block. 2. Make the item a display item by setting its Database Item property to No. 3. Set the item's Data Type, Maximum Length, and other properties to be compatible with the type of fetched values the item will display. 4. Write the necessary triggers to populate the control item at runtime.
Example
BEGIN SELECT rtrim(swriden_last_name,' ')||', '|| rtrim(swriden_first_name,' ')||' '|| swriden_mi INTO :name FROM swriden WHERE swriden_id = :swriden_id; EXCEPTION WHEN NO_DATA_FOUND THEN Message('Invalid ID. Please enter again.'); RAISE FORM_TRIGGER_FAILURE; END;
SunGard 2004-2008
Page 129
Oracle Forms 6i
IF :DATE_ENROLLED > :DATE_GRADUATED THEN MESSAGE('The date of enrollment must occur before the date of graduation'); RAISE FORM_TRIGGER_FAILURE; END IF;
SunGard 2004-2008
Page 130
Oracle Forms 6i
Exercise 24
In the Address data block, create a trigger to populate the address description item whenever validation occurs on swraddr_atyp_code (use STVATYP). Fail the trigger and display a suitable message if the swraddr_atyp_code is not found. Run the form, and enter a new address with an incorrect address type. Enter a correct address type to see if the display item populates.
SunGard 2004-2008
Page 131
Oracle Forms 6i
Exercise 25
In the Address data block, create a trigger to populate the state description whenever validation occurs.
Exercise 26
Delete the swriden_last_name and swriden_first_name items and create one non-database item called name on the swriden block. Create a trigger that will populate the name after an ID is entered. If the ID is invalid, fail the trigger and display a suitable message.
SunGard 2004-2008
Page 132
Oracle Forms 6i
Query Triggers
Introduction
Query triggers allow you to control events just before and just after a query.
Objectives
This section will examine the following: Query processing flowchart Triggers which screen query triggers Triggers which supplement query results
SunGard 2004-2008
Page 133
Oracle Forms 6i
Query Processing
Diagram
SunGard 2004-2008
Page 134
Oracle Forms 6i
PRE-QUERY
Pre-Query triggers
Fires during Execute Query or Count Query processing, just before Oracle Forms constructs and issues the SELECT statement to identify rows that match the query criteria. Use a Pre-Query trigger to modify the example record that determines which rows will be identified by the query.
On Failure
The query is canceled. If the operator or the application had placed the form in Enter Query mode, the form would remain in Enter Query mode.
Example
This example validates or modifies query criteria for a database data block query.
BEGIN IF :SWRIDEN_ID IS NULL THEN Message('Id must be entered for Query.'); RAISE Form_Trigger_Failure; END IF; END;
SunGard 2004-2008
Page 135
Oracle Forms 6i
POST-QUERY
Post-Query triggers
When a query is open in the data block, the Post-Query trigger fires each time Oracle Forms fetches a record into a data block. The trigger fires once for each record placed on the data block's list of records. Use a Post-Query trigger to perform the following tasks: populate control items or items in other data blocks calculate statistics about the records retrieved by a query calculate a running total
On Failure
Oracle Forms flushes the record from the data block and attempts to fetch the next record from the database. If there are no other records in the database, Oracle Forms closes the query and waits for the next operator action.
Example
SELECT INTO FROM WHERE description detc_desc twvdetc detc_code = :Account.detc_code;
Exercise 27
Create a post-query trigger on the SWRADDR block to populate the atyp_desc field.
SunGard 2004-2008
Page 136
Oracle Forms 6i
SunGard 2004-2008
Page 137
Oracle Forms 6i
System Modes
Syntax
SYSTEM.MODE
Description
SYSTEM.MODE indicates whether the form is in Normal, Enter Query, or Fetch Processing mode. The value is always a character string. Mode NORMAL ENTER-QUERY QUERY Description Indicates that the form is currently in normal processing mode. Indicates that the form is currently in Enter Query mode. Indicates that the form is currently in fetch processing mode, meaning that a query is currently being processed.
Exercise 28
Ensure that the Exit button has no effect in Enter Query Mode.
SunGard 2004-2008
Page 138
Oracle Forms 6i
Transaction Triggers
Introduction
When a form's changes are saved during runtime, Oracle Forms enables you to fire triggers before and after events to control these actions.
Objectives
This section will examine the following: What is a transaction? What happens during transaction processing? Learn triggers which can be added to enhance transaction processing
SunGard 2004-2008
Page 139
Oracle Forms 6i
Transactions
What is a transaction?
An Oracle Forms transaction is considered to be the set of all DML statements made between saves. If the user saves changes three times during the day, then three transactions occurred.
SunGard 2004-2008
Page 140
Oracle Forms 6i
SunGard 2004-2008
Page 141
Oracle Forms 6i
Pre-insert trigger
A pre-insert trigger is a good place to generate a one-up-number or to obtain the activity date for the record. Example: SELECT swriden_pidm_sequence.NEXTVAL INTO :swriden.pidm FROM sys.dual;
Pre-update trigger
A pre-update trigger is a good place to update the activity date or the user who is making the change to the record.
:swraddr.activity_date := sysdate;
Exercise 29
In both the Address and Person data blocks, create triggers that populate the activity date and pidm when the user saves a new record.
SunGard 2004-2008
Page 142
Oracle Forms 6i
Exercise 30
In both the Address and Person data blocks, create a trigger that populates the activity date when the user updates an existing record.
SunGard 2004-2008
Page 143
Oracle Forms 6i
Pre-delete trigger
To ensure that detail records do not exist before a master record is deleted, you can use the pre-delete trigger.
Example
BEGIN SELECT 'X' INTO :global.dummy FROM swraddr WHERE swraddr.pidm = :swriden.pidm; WHEN SQL%FOUND THEN MESSAGE('Data found in address table. Identification record.'); RAISE FORM_TRIGGER_FAILURE; EXCEPTION WHEN NO_DATA_FOUND THEN NULL; END;
Cannot delete
SunGard 2004-2008
Page 144
Oracle Forms 6i
Usage notes
Use a Pre-Commit trigger to perform an action, such as setting up special locking requirements, anytime a database commit is going to occur.
On failure
The Post and Commit process fails: No records are written to the database and focus remains in the current item.
POST-FORMS-COMMIT
Fires once during the Post and Commit Transactions process. If there are records in the form that have been marked as inserts, updates, or deletes, the Post-Forms-Commit trigger fires after these changes have been written to the database but before Oracle Forms issues the database Commit to finalize the transaction. If the operator or the application initiates a Commit when there are no records in the form have been marked as inserts, updates, or deletes, Oracle Forms fires the Post-FormsCommit trigger immediately, without posting changes to the database.
Usage notes
Use a Post-Forms-Commit trigger to perform an action, such as updating an audit trail, anytime a database commit is about to occur.
SunGard 2004-2008
Page 145
Oracle Forms 6i
On failure
Aborts post and commit processing: Oracle Forms issues a ROLLBACK and decrements the internal Savepoint counter.
POST-DATABASE-COMMIT
Fires once during the Post and Commit Transactions process, after the database commit occurs. Note that the Post-Forms-Commit trigger fires after inserts, updates, and deletes have been posted to the database, but before the transaction has been finalized by issuing the Commit. The Post-Database-Commit Trigger fires after Oracle Forms issues the Commit to finalize the transaction.
Usage notes
Use a Post-Database-Commit trigger to perform an action anytime a database commit has occurred.
On failure
There is no rollback, because at the point at which this trigger might fail, Oracle Forms has already moved past the point at which a successful rollback operation can be initiated as part of a failure response.
SunGard 2004-2008
Page 146
Oracle Forms 6i
Introduction
Lists of Values provide the user with choices of values for a given item. A List of Values can contain either suggestions or a validation list.
Objectives
This section will examine the following: What can LOVs do? How do I create an LOV?
SunGard 2004-2008
Page 147
Oracle Forms 6i
SunGard 2004-2008
Page 148
Oracle Forms 6i
Specify whether your LOV will be based on an existing record group or create a new query record group.
Screen image
SunGard 2004-2008
Page 149
Oracle Forms 6i
Screen image
Additional Buttons
Click the Connect button to connect with the database if you are not currently connected. Click the Check Syntax button to verify the validity of the query.
SunGard 2004-2008
Page 150
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 151
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 152
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 153
Oracle Forms 6i
Screen image
SunGard 2004-2008
Page 154
Oracle Forms 6i
Screen image
If the LOV is not currently attached, then attach it to a text item, or write a trigger to display the LOV programmatically. Now under the LOV list is LOVxx and under the Record Group list is LOVxx. Rename the record group to STVATYP_RG and the LOV to STVATYP_LOV.
SunGard 2004-2008
Page 155
Oracle Forms 6i
SunGard 2004-2008
Page 156
Oracle Forms 6i
Exercise 31
Add an address type button to invoke the stvatyp_lov.
SunGard 2004-2008
Page 157
Oracle Forms 6i
Canvases, Part II
Introduction
A GUI environment takes advantage of tiling, minimizing, cascading, etc. Oracle Forms allows you to take advantage of these GUI attributes.
Objectives
This section will examine the following: Creating and modifying Content Canvases Types of canvases Windows and their properties
SunGard 2004-2008
Page 158
Oracle Forms 6i
About Canvases
Types of canvases
Content Canvas Stacked Canvas Toolbar Canvas Tab Canvas
SunGard 2004-2008
Page 159
Oracle Forms 6i
Stacked Canvas
Characteristics
A stacked canvas is displayed in a window on top of, or "stacked" on the content canvas assigned to that same window. Stacked canvases obscure some part of the underlying content canvas, and are often shown and hidden programmatically More than one stacked canvas can be displayed in a window at the same time
3. Click and drag the mouse in the canvas to the position where you want to place the stacked canvas. 4. Open the Properties Palette and set the properties of the canvas object as described on the next page.
SunGard 2004-2008
Page 160
Oracle Forms 6i
Width/Height Bevel
Viewport Width / Viewport Height Viewport X Position / Viewport Y Position Show Horizontal Scrollbar / Show Vertical Scrollbar
Positioning
If the stacked canvas is not being shown programmatically or in response to navigation, make sure that its position in the canvas stacking order places it in front of the content canvas assigned to the same window. If it is not, it will be shown behind the content canvas, and will not be visible at runtime.
SunGard 2004-2008
Page 161
Oracle Forms 6i
Stacking order
The stacking order of canvases in a window is defined by the sequence in which they are listed under the Canvases node in the Object Navigator.
To hide the stacked canvas, hold the [Shift] key and select the appropriate stacked canvas.
Exercise 32
Create a new block and canvas called Comment and add items from the swrcmnt table. Change the canvas type to stacked. Don't forget the swrcmnt_cmtt_code LOV.
SunGard 2004-2008
Page 162
Oracle Forms 6i
Exercise 33
Create a new window called Window2 in the SWAIDEN form, suitable for presenting Comment. Associate comment with WINDOW2 Modify the height and width properties Add a title for the window Define a display position that is different than Window1, so that it appears below the name information displayed on CANVAS1 Set the Hide on Exit property to Yes
SunGard 2004-2008
Page 163
Oracle Forms 6i
Exercise 34
Associate CANVAS2 (Personal Information) with Window2. Run the form to see the differences.
SunGard 2004-2008
Page 164
Oracle Forms 6i
Toolbar Canvas
Characteristics
Toolbar canvases are used to create toolbars for individual windows. Horizontal toolbars are displayed at the top of a window, just under its menu bar Vertical toolbars are displayed along the left side of a window MDI toolbars are used to avoid creating multiple toolbars for a Multi-Form Application. Banner uses MDI Toolbars for its forms Associate the toolbar with a window, and remember to update the window's toolbar property
SunGard 2004-2008
Page 165
Oracle Forms 6i
Create a toolbar
1. In the Object Navigator, position the cursor on the Canvases node. 2. Choose NavigatorCreate to insert a new canvas in the object hierarchy. 3. In the Property Palette, set the properties of the canvas as follows: Property Canvas Type Window Width/Height Usage Set to Horizontal Toolbar or Vertical Toolbar. Specify the window on which you want the toolbar to display. Oracle Forms will display whatever size toolbar you create, even one that completely obscures the window's content canvas-view. It is up to you to set the Width and Height properties to appropriate values, depending on how large you want the toolbar to be.
4. For the window to which you assigned the toolbar canvas, set the Horizontal Toolbar Canvas or Vertical Toolbar Canvas property by specifying the name of the toolbar canvas you created in step 2. 5. For the Form to which you want to assign a MDI Toolbar, set the Form Horizontal Toolbar Canvas or Form Vertical Toolbar Canvas property by specifying the name of the toolbar canvas you created in step 2. 6. Add items and boilerplate graphics to the toolbar canvas as you would for any other canvas.
SunGard 2004-2008
Page 166
Oracle Forms 6i
Tab Canvas
Characteristics
A tab canvas is displayed in a window on top of the content canvas assigned to that same window. Tab canvases enable you to organize and display related information on separate tabs Tab canvases are made up of one or more tab pages, which have labeled tabs that comprise an equal amount of space on the tab canvas Tab canvases can be used to display large amount of information on a single canvas and give the application a Web feel
SunGard 2004-2008
Page 167
Oracle Forms 6i
3. Click and drag the mouse in the canvas to the position where you want to place the tab canvas. 4. Open the Properties Palette and set the properties of the canvas object as described below. 5. Create additional tab pages in the Object Navigator. 6. Set the tab page properties as described below. 7. Create additional tab pages by repeating steps 5 and 6.
SunGard 2004-2008
Page 168
Oracle Forms 6i
Width/Height Bevel
Viewport Width / Viewport Height Viewport X Position / Viewport Y Position Corner Style Tab Attachment Edge
SunGard 2004-2008
Page 169
Oracle Forms 6i
Stacking order
If the tab canvas is not being shown programmatically or in response to navigation, make sure that its position in the canvas stacking order places it in front of the content canvas assigned to the same window. If it is not, it will be shown behind the content canvas, and will not be visible at runtime. The stacking order of canvases in a window is defined by the sequence in which they are listed under the Canvases node in the Object Navigator.
To hide the tab canvas, hold the [Shift] key and select the appropriate tab canvas.
SunGard 2004-2008
Page 170
Oracle Forms 6i
Introduction
By default, Oracle and Forms messages appear to the user during runtime. You can add your own messages, and replace the default error and warning messages that Forms displays.
Objectives
This section will examine the following: Message types Replacing system messages Creating and displaying alerts
SunGard 2004-2008
Page 171
Oracle Forms 6i
Login failed for this username and password. Too many values
Warning messages, such as: FRM-10205: Menu <menu module name> not found. Working messages, such as: Attempting to reserve record for update or delete (CTRL-C to cancel)...
SunGard 2004-2008
Page 172
Oracle Forms 6i
Syntax
MESSAGE(message_string); To display the value of a variable with text: MESSAGE('message string'||variable);
Example
IF :Account.bill_date > :Account.paid_date THEN MESSAGE('Bill date cannot be greater than date paid'); END IF;
SunGard 2004-2008
Page 173
Oracle Forms 6i
SunGard 2004-2008
Page 174
Oracle Forms 6i
Intercepting functions
To capture error details, you can use the built-in functions ERROR_CODE, ERROR_TEXT, ERROR_TYPE. To capture informative message details, you can use the built-in functions MESSAGE_CODE, MESSAGE_TEXT, MESSAGE_TYPE.
ON-ERROR Example
DECLARE errnum NUMBER := ERROR_CODE; errtxt VARCHAR2(80) := ERROR_TEXT; errtyp VARCHAR2(3) := ERROR_TYPE; BEGIN IF errnum = 40301 THEN Message('Your search criteria identified no matches... Try Again.'); ELSE /* ** Print the Normal Message that would have appeared ** ** Default Error Message Text Goes Here */ Message(errtyp||'-'||TO_CHAR(errnum)||': '||errtxt); RAISE Form_Trigger_Failure; END IF; END;
SunGard 2004-2008
Page 175
Oracle Forms 6i
Alerts
Alerts
An alert is a modal window that displays a message notifying the operator of some application condition. The operator must respond to the alert's message by selecting one of the predefined alert buttons. Selecting any button immediately dismisses the alert.
SunGard 2004-2008
Page 176
Oracle Forms 6i
Create an alert
To create an alert: 1. In the Navigator, select the Alerts node and then choose NavigatorCreate. 2. In the Property Palette window, set the Alert Style property to the style that corresponds to the severity of your message. Valid choices are Stop, Caution, or Note. At runtime, an icon representing the style you select displays next to the message in the alert window. 3. Set the Message property by entering the message you want the alert to display at runtime. You can enter up to 200 characters. 4. Define one or more buttons for the alert by entering a text label in the Button 1, Button 2, and Button 3 fields. (The default text labels are OK for Button 1 and Cancel for Button 2.) 5. At least one button must have a label. Buttons that do not have labels are not displayed. 6. Choose the Default Alert Button, either Button 1, Button 2, or Button 3. 7. The default button is the button that is selected implicitly when the operator presses [Accept]. On most window managers, the default button has a distinctive appearance.
SunGard 2004-2008
Page 177
Oracle Forms 6i
Example
DECLARE alert_button NUMBER; BEGIN IF :Account.bill_date > :Account.paid_date THEN alert_button := SHOW_ALERT('invalid_billing_dates'); END IF; END;
SunGard 2004-2008
Page 178
Oracle Forms 6i
Example
The following example changes the message of an alert named generic_alert. This alert is informational only and has only one button, labeled "OK":
DECLARE alert_button NUMBER; BEGIN IF :Account.bill_date > :Account.paid_date THEN Set_Alert_Property('Date_Alert', ALERT_MESSAGE_TEXT, 'The Bill date cannot be after the date paid.'); alert_button := SHOW_ALERT('Date_Alert'); END IF; END;
SunGard 2004-2008
Page 179
Oracle Forms 6i
Exercise 35
Create an alert called HELP_ALERT. The alert should be a Note type, with one OK button Briefly describe what the form is used for within the message property Create a button called help that will show the help alert message Assign the canvas to the main canvas
SunGard 2004-2008
Page 180
Oracle Forms 6i
SunGard 2004-2008
Page 181
Oracle Forms 6i
Syntax
GET_ITEM_PROPERTY(item_name, property); To obtain more information about the parameters the function accepts, explore the Forms Builder Help.
Example
/* Hides the account button if it is displayed. */ IF GET_ITEM_PROPERTY('Control.account_btn',DISPLAYED) = 'TRUE' THEN SET_ITEM_PROPERTY('Control.account_btn', DISPLAYED, PROPERTY_FALSE); END IF;
WHEN-MOUSE-DOWN trigger
/* Obtains the name and coordinates of the item the mouse is on. */ DECLARE item_var VARCHAR2(30); x_posn NUMBER; y_posn NUMBER; BEGIN item_var := GET_ITEM_PROPERTY(:SYSTEM.MOUSE_ITEM,ITEM_NAME); x_posn := GET_ITEM_PROPERTY(:SYSTEM.MOUSE_ITEM,X_POS); y_posn := GET_ITEM_PROPERTY(:SYSTEM.MOUSE_ITEM,Y_POS); . . . END;
SunGard 2004-2008
Page 182
Oracle Forms 6i
Exercise 36
Alter the trigger so that Help button disappears when the form is in Enter Query Mode Use the built-in subprogram SET_ITEM_PROPERTY. Examine the parameters it takes by opening the Forms Builder Help.
SunGard 2004-2008
Page 183
Oracle Forms 6i
Introduction
Oracle Forms was designed so that objects and code could be reused and shared.
Objectives
This section will examine the following: Property Classes Object Groups Copying and Subclassing Objects
SunGard 2004-2008
Page 184
Oracle Forms 6i
Property Classes
Property classes
A property class is a named object that contains a list of properties and their settings. Once you create a property class, you can base other objects on it. An object based on a property class can inherit the setting of any property in the class that makes sense for that object.
Characteristics
Property class inheritance is a powerful feature that allows you to quickly define objects that conform to your own interface and functionality standards Property classes also allow you to make global changes to applications quickly. By simply changing the definition of a property class, you can change the definition of all objects that inherit properties from that class
SunGard 2004-2008
Page 185
Oracle Forms 6i
SunGard 2004-2008
Page 186
Oracle Forms 6i
Inherited Property
Takes its value from the property class that is associated with the object. Displayed in the Property Palette with an arrow.
Variant Property
Has modified the inherited value from the property class that is associated with the object Displayed in the Property Palette with a cross over the arrow
SunGard 2004-2008
Page 187
Oracle Forms 6i
Exercise 37
Create a property class called DATE_CLASS. Set the initial value to the database date Set the format mask Set the background color Set enabled to no Set keyboard navigable to no Set the datatype to type date Set the maximum length to 11
SunGard 2004-2008
Page 188
Oracle Forms 6i
Object Groups
Object groups
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 reference them in another module. Object groups provide a way to bundle objects into higher-level building data blocks that can be used in other parts of an application and in subsequent development projects. Once you create an object group, you can add and remove objects to it as desired.
2. In the Object Navigator, drag the desired object(s) under the Object Group Children node.
SunGard 2004-2008
Page 189
Oracle Forms 6i
SunGard 2004-2008
Page 190
Oracle Forms 6i
Multiple-Form Applications
Introduction
So far, you have run one form at a time to view and modify data. However, rarely would an application consist of one form. In this section, you connect your two forms together by having one call the other.
Objectives
This section will examine the following: Methods of calling one form from another How to establish variables which can be used across forms
SunGard 2004-2008
Page 191
Oracle Forms 6i
Invoking forms
There are three ways that one form can programmatically invoke another form: Execute the OPEN_FORM procedure to open an independent form Execute the NEW_FORM procedure to replace the current form with a different form Execute the CALL_FORM procedure to call a modal form
SunGard 2004-2008
Page 192
Oracle Forms 6i
OPEN_FORM
Procedure
The first form remains displayed, and operators can navigate between the forms as desired. The new form can share the same database session as the form from which it was invoked, or it can create a separate session of its own.
Syntax
OPEN_FORM(form_name [,activate_mode] [,session_mode] [,data_mode] [,paramlist_id]);
SunGard 2004-2008
Page 193
Oracle Forms 6i
Description Specifies the name of the form to open. ACTIVATE: Sets focus to the form to make it the active form in the application. NO_ACTIVATE: Opens the form but does not set focus to the form. The current form remains current.
session_mode
NO_SESSION: Specifies that the opened form should share the same database session as the current form. A COMMIT operation in any form will cause validation and commit processing to occur for all forms running in the same session. SESSION: Specifies that a new, separate database session should be created for the opened form.
data_mode
NO_SHARE_LIBRARY_DATA: At runtime, Form Builder will not share data between forms that have identical libraries attached (At design time). SHARE_LIBRARY_DATA: At runtime, Form Builder will share data between forms that have identical libraries attached (At design time).
paramlist_name paramlist_id
Specifies the CHAR name of a parameter list to be passed to the opened form. Specifies the unique ID that Oracle Forms assigns to the parameter list at the time it is created. Use the GET_PARAMETER_LIST function to return the ID to a variable of type PARAMLIST.
SunGard 2004-2008
Page 194
Oracle Forms 6i
CALL_FORM Built-In
Procedure
Runs an indicated form while keeping the parent form active. Oracle Forms runs the called form with the same Runform preferences as the parent form. 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. When you call a form, Oracle Forms issues a savepoint for the called form. If the CLEAR_FORM function causes a rollback when the called form is current, Oracle Forms rolls back uncommitted changes to this savepoint.
SunGard 2004-2008
Page 195
Oracle Forms 6i
Syntax
CALL_FORM(formmodule_name [, display][, switch_menu] [, query_mode] [, data_mode] [, paramlist_name]); Parameter formmodule_name display Value Specifies the form module name of the called form. HIDE causes Oracle Forms to clear the calling form from the screen before drawing the called form. HIDE is the default parameter. NO_HIDE causes Oracle Forms to display the called form without clearing the calling form from the screen. switch_menu NO_REPLACE causes Oracle Forms to keep the default menu application of the calling form active for 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. query_mode NO_QUERY_ONLY causes Oracle Forms to run the indicated form in normal mode, allowing the operator to perform inserts, updates, and deletes from within the called form. QUERY_ONLY causes Oracle Forms to run the indicated form in Query Only mode, allowing the operator to query, but not to insert, update, or delete records. data_mode NO_SHARE_LIBRARY_DATA At runtime, Form Builder will not share data between forms that have identical libraries attached (At design time). SHARE_LIBRARY_DATA At runtime, Form Builder will share data between forms that have identical libraries attached (At design time). paramlist_id Specifies the unique ID Oracle Forms assigns when it creates the parameter list. You can optionally include a parameter list as initial input to the called form. The data type of the ID is PARAMLIST. The name you gave the parameter list object when you defined it.
paramlist_name
SunGard 2004-2008
Page 196
Oracle Forms 6i
Example
/* ** Built-in: CALL_FORM ** Example: Calls a form in query-only mode. */ BEGIN Call_Form('SOAIDEN',NO_HIDE,NO_REPLACE,QUERY_ONLY); END;
SunGard 2004-2008
Page 197
Oracle Forms 6i
NEW_FORM Built-In
Procedure
Exits the current form and enters the indicated form. The calling form is terminated as the parent form. Oracle Forms runs the new form with the same Runform options as the parent form. If the parent form was a called form, Oracle Forms runs the new form with the same options as the parent form.
SunGard 2004-2008
Page 198
Oracle Forms 6i
Syntax
NEW_FORM(formmodule_name [, rollback_mode] [,query_mode] [, data_mode] [, paramlist_name] ); Parameter formmodule_name Value Specifies the form module name of the called form. The name must be enclosed in single quotes. The data type of the name is CHAR. TO_SAVEPOINT rolls back all uncommitted changes (including posted changes) to the current form's savepoint. NO_ROLLBACK exits the current form without rolling back to a savepoint. FULL_ROLLBACK rolls back all uncommitted changes (including posted changes) that were made during the current Runform session. query_mode NO_QUERY_ONLY runs the indicated form normally, allowing the operator to perform inserts, updates, and deletes in the form. QUERY_ONLY runs the indicated form as a query-only form. data_mode NO_SHARE_LIBRARY_DATA At runtime, Form Builder will not share data between forms that have identical libraries attached (At design time). SHARE_LIBRARY_DATA At runtime, Form Builder will share data between forms that have identical libraries attached (At design time). paramlist_id paramlist_name Specifies the unique ID Oracle Forms assigns when it creates the parameter list. The name you gave the parameter list object when you defined it. The data type of the name is CHAR. A parameter list passed to a form via NEW_FORM cannot contain parameters of type DATA_PARAMETER (a pointer to record group).
rollback_mode
SunGard 2004-2008
Page 199
Oracle Forms 6i
Global Variables
Global variables
A global variable is an Oracle Forms variable whose value is accessible to triggers and subprograms in any module that is active during the current session. A global variable stores a character string of up to 255 characters in length. Because global variables are accessible throughout an entire session, they are frequently used to keep track of variables used in a multiple-form application.
Declaration
Global variables are not formally declared the way PL/SQL local variables are. Rather, you initialize a global variable the first time you assign a value to it: :GLOBAL.pidm := TO_CHAR(:swriden_pidm);
Referencing
To reference a global variable, prefix the variable name with the word GLOBAL and a colon. Referencing a global variable that has not been initialized through assignment causes a runtime error.
Destruction
To destroy a global variable and release its memory, use the ERASE built-in procedure: erase('GLOBAL.pidm');
SunGard 2004-2008
Page 200
Oracle Forms 6i
DEFAULT_VALUE
Procedure
You can use the DEFAULT_VALUE built-in procedure to assign a value to a variable whose value is NULL. If the value of the indicated variable is not NULL, DEFAULT_VALUE does nothing. If the variable to which the value is being assigned is an undefined global variable, Oracle Forms creates the variable.
Example
The following example creates a global variable named pidm and initializes it to '': Default_Value('','GLOBAL.pidm');
SunGard 2004-2008
Page 201
Oracle Forms 6i
Form_header
Non-database datablock Items: workfld callfld workdate current_institution current_release current_form current_date current_time
SunGard 2004-2008
Page 202
Oracle Forms 6i
Key block
The first block on most forms contains key information. (Some forms, especially validation forms and certain list forms, do not have a key block.) The key block determines what is entered or displayed on the rest of the form. All information on the form refers to the key block. The key block has at least one field and sometimes more. For example, a form that maintains population selection information may have key block fields for both an application and a selection ID. The key block stays on the form as subsequent blocks appear. Occasionally, another window may appear on top of the key block if the window is unusually large or if the key block is not pertinent to the window. When the cursor is in the key block, enterable fields in the key block are enabled. When you leave the key block, enterable fields in the key block are disabled.
SunGard 2004-2008
Page 203
Oracle Forms 6i
Conversion
Process
To begin conversion: Rename the swriden block to Key_block Change the block to a non-database data block Change all items to non-database items
SunGard 2004-2008
Page 204
Oracle Forms 6i
Answer Guide
Introduction
This section contains answers for the workbook's exercises.
SunGard 2004-2008
Page 205
Oracle Forms 6i
Answer Guide
Exercise 1
Create a new form module called SWAIDEN. The naming convention follows Banner standards. SWAIDEN stands for: Student Custom object Application form Identification
SunGard 2004-2008
Page 206
Oracle Forms 6i
Exercise 2
In the new form module, create a data block based on the SWRIDEN table. Do not include the swriden_change_ind and swriden_activity_date columns. The Identification data block should be displayed on Canvas1. Display Forms Style. Title the Frame Identification and only display one record.
In the new form, select Tools->Data Block Wizard. When the dialog appears, enter the following properties: Base Table: SWRIDEN Frame Name: Identification Style: Form Canvas: (New Canvas) Records: 1 Deselect swriden_change_ind and swriden_activity_date columns so they do not appear.
Exercise 4
In the Address data block, allow the user to automatically navigate to the next record when tabbing, by modifying the Navigation Style on the data block level. Navigation Style: Change Record
SunGard 2004-2008
Page 207
Oracle Forms 6i
Exercise 5
In the SWRIDEN block, increase the number of records displayed to 5
Exercise 6
Ensure that the records retrieved in the SWRIDEN data block are current (the swriden_change_ind is NULL) by adding a WHERE clause.
Exercise 7
Sort the records in the SWRIDEN data block by last name.
Exercise 8
Make sure the user is unable to insert, update, or delete records in the ID data block.
Exercise 9
(No solution)
Exercise 10
Join both the swraddr and swbpers blocks to the swriden pidm
Block property address block where clause :swriden_pidm = swraddr_pidm person block where clause :swriden_pidm = swbpers_pidm
SunGard 2004-2008
Page 208
Oracle Forms 6i
Exercise 11
In the SPRIDEN data block, set the canvas to null within the pidm item's property palette.
Exercise 12
In both the Address and Person data blocks: Alter the activity date so that it initializes to the current database date for a new record. Try using an intersection to set the property for both items at the same time For both data blocks, do not allow the activity date to be updated or inserted by the user Set the bubble help to Activity Date Set the format mask so that the date appears like the following: 01-JAN-1998 Remember to alter the maximum length to allocate for the increase in characters
To create an intersection: within the Object Navigator, highlight activity date in both the Address and Person data blocks. To highlight items, click the first item, and then hold the [Ctrl] key and click the second item. Enter the Property Palette by selecting Tools_Property Palette. Set the following properties: Format Mask: DD-MON-YYYY Initial Value: $$DBDATE$$ Maximum Length: 11 Update Allowed: No Insert Allowed: No Tooltip: Activity Date
SunGard 2004-2008
Page 209
Oracle Forms 6i
Exercise 13
In the Person data block, set the format mask for birth_date so that it appears like the following: 01-JAN-1998. Set the bubble help to Birth Date. Format Mask: DD-MON-YYYY Maximum Length: 11 Tooltip: Birth Date
Exercise 14
In the Person data block, set the format mask for swbpers_ssn so that it appears like the following at runtime: 123-45-6789. Set Fixed Length to Yes. Format Mask: 999-99-9999 Fixed Length: Yes Maximum Length: 11
Exercise 15
In the Address data block, set the format mask for the phone number so that it appears like the following at runtime: 555-1212. Set Fixed Length to Yes. Format Mask: 999-9999 Fixed Length: Yes Maximum Length: 8
SunGard 2004-2008
Page 210
Oracle Forms 6i
Exercise 16
In the Address data block, create a new display item named atyp_desc. Ensure that atyp_desc is not a base table item Assign the item to Canvas1 Set the bubble help to Address Description The display item will be populated by a trigger in a later exercise On the canvas, place it to the right of the swraddr_atyp_code
In the Address data block, highlight the Items node and select Navigator->Create. In the property sheet, set the following properties: Item Type: Display Item Canvas: Canvas1 Database Item: No
SunGard 2004-2008
Page 211
Oracle Forms 6i
Exercise 17
In the Person data block, convert the swbpers_confid_ind text item to a check box. Set the checked state to represent the base table value of Y and the unchecked state to represent N Ensure that new records are automatically assigned the value N Allow only those records with swbpers_confid_ind values of Y or N to display Resize the checkbox appropriately
Set the following properties for swbpers_confid_ind: Item Type: Check Box Initial Value: N Label: Confid Value When Checked: Y Value When Unchecked: N Check Box Mapping of Other Values: Not Allowed
SunGard 2004-2008
Page 212
Oracle Forms 6i
Exercise 18
In the Person data block, convert the swbpers_mrtl_code text item to a pop-list list item. Add list elements of Single, Married, Widowed, and Divorced to represent database values of S, M, W, and D Display any other values as Single Ensure that new records display the default value Single Resize the list item to see your choices at runtime
Within the swbpers_mrtl_code Property Palette, set the following properties: Item Type: List Item Initial Value: S Mapping of Other Values: S List Style: Poplist
Double-click List Elements, and enter: List element Single Married Widowed Divorced List item value S M W D
SunGard 2004-2008
Page 213
Oracle Forms 6i
Exercise 19
In the Person data block, convert the swbpers_sex text item into a radio group. Add radio buttons for Male and Female to represent the database values of M and F Define access keys of M for male and F for female Define a default value of M for all new records
Enter the following properties for the swbpers_sex item: Item Type: Radio Group Initial Value: M
Create two radio buttons underneath the group, and set the following properties: Name Access Key Label Radio Button Value Male M Male M Female F Female F
SunGard 2004-2008
Page 214
Oracle Forms 6i
Exercise 20
Create a control data block. Create three non-database items and convert all of them to push buttons: Button 1 Label: Person Add trigger when-button-pressed and enter go_block('SWBPERS'); Place on canvas1 Button 2 Label: Return Add trigger when-button-pressed and enter go_block('SWRIDEN'); Place on canvas2 Button 3 Label: Exit Add trigger when-button-pressed and enter exit form; Place on canvas1
Exercise 21
At the form level, create a trigger to immediately execute a query. At both block levels for SWRADDR and SWBPERS when the block is entered also, execute a query. Add trigger when-new-form-instance go_block('swraddr'); execute_query; go_block('swbpers'); execute_query; go_block('swriden');
SunGard 2004-2008
Page 215
Oracle Forms 6i
Exercise 22
When navigating to the next record in the ID block, get the records in the address block to change as well. Add trigger when-new-record-instance go_block('swraddr'); execute_query; go_block('swbpers'); execute_query; go_block('swriden');
Exercise 23
Write a PRE-FORM trigger in SWAIDEN, which checks the username. If the name does not match your username, fail the trigger and display a message. Use the built-in subprogram GET_APPLICATION_PROPERTY. Attempt to run your form under a different training account. What occurred? IF get_application_property(username) = 'TRAIN03' then message('You do NOT have access to this form!'); raise form_trigger_failure; end if;
Exercise 24
In the Address data block, create a trigger to populate the address description item whenever validation occurs on swraddr_atyp_code (use STVATYP). Fail the trigger and display a suitable message if the swraddr_atyp_code is not found.
begin select stvatyp_desc into :atyp_desc; from stvatyp where stvatyp_code = :swraddr_atyp_code; exception when no_data_found then message('Invalid Address Type Code!'); message('Invalid Address Type Code!'); raise form_trigger_failure; end;
SunGard 2004-2008
Page 216
Oracle Forms 6i
Exercise 25
In the Address data block, create a trigger to populate the state description on whenever validation occurs.
begin select stvstat_desc into :swraddr.stat_desc from stvstat where stvstat_code = :swraddr_stat_code; exception when no_data_found then message('Invalid State Code!'); message('Invalid State Code!'); raise form_trigger_failure; end;
Exercise 26
Delete the last_name and first_name items and create one non-database item called name on the swriden block. Create a trigger that will populate the name after an ID is entered. If the ID is invalid, fail the trigger and display a suitable message. Delete first name item Change last name item to a non-database item Change the item name to name
BEGIN SELECT rtrim(swriden_last_name,' ')||', '|| rtrim(swriden_first_name,' ')||' '|| swriden_mi INTO :name FROM swriden WHERE swriden_id = :swriden_id; EXCEPTION WHEN NO_DATA_FOUND THEN Message('Invalid ID. Please enter again.'); RAISE FORM_TRIGGER_FAILURE; END;
SunGard 2004-2008
Page 217
Oracle Forms 6i
Exercise 27
Create a post-query trigger on the SWRADDR block to populate the atyp_desc field. declare cursor c1 is select stvatyp_desc from stvatyp where stvatyp_code = :swraddr_atyp_code; begin open c1; fetch c1 into :swraddr.addr_desc; exception when no_data_found then message('Invalid Address Type Code!'); raise form_trigger_failure; close c1; end;
Exercise 28
Ensure that the Exit button has no effect in Enter Query Mode. Highlight the WHEN-BUTTON-PRESSED trigger underneath the Exit_Btn. Enter the property sheet and set the following:
SunGard 2004-2008
Page 218
Oracle Forms 6i
Exercise 29
In both the Address and Person data blocks, create triggers that populate the activity date and pidm when the user saves a new record. Create a PRE-INSERT trigger defined under the Address and Person data blocks. Enter the following code:
Exercise 30
In both the Address and Person data blocks, create a trigger that populates the activity date when the user updates an existing record. Create a PRE-UPDATE trigger defined under the Address and Person data blocks. Enter the following code:
Exercise 31
Add an address type button to invoke the stvatyp_lov. Create a push button in the control_block.
SunGard 2004-2008
Page 219
Oracle Forms 6i
Exercise 32
Create a new block and canvas called Comment and add items from the sprcmtt table. Change the canvas type to stacked. Don't forget the swrcmnt_cmtt_code LOV. Right click data blocks Select data block wizard Include all columns In the layout wizard Select new canvas type stacked Display all items
Exercise 33
Create a new window called Window2 in the SWAIDEN form, suitable for presenting Comment. Associate comment with WINDOW2 Modify the height and width properties Add a title for the window Define a display position that is different than Window1, so that it appears below the name information displayed on CANVAS1 Set the Hide on Exit property to Yes Title: Comment Primary Canvas: Comment Hid on Exit: Yes Physical X position: 0 Physical Y position: 275 Width: 530 Height: 128
SunGard 2004-2008
Page 220
Oracle Forms 6i
Exercise 34
Associate CANVAS2 (Personal Information) with Window2. Run the form to see the differences.
Exercise 35
Create an alert called HELP_ALERT. The alert should be a Note type, with one OK button Briefly describe what the form is used for within the message property Create a button called help that will show the help alert message assign the button to the main canvas Highlight alerts Click the create icon Title the alert Help ID, address and personal information form Create an item in the control block and change the type to push button Create a when-button-pressed trigger on the button and add:
SunGard 2004-2008
Page 221
Oracle Forms 6i
Exercise 36
Alter the trigger so that the Help button disappears when the form is in Enter Query Mode. Use the built-in subprogram SET_ITEM_PROPERTY. Examine the parameters it takes by opening the Forms Builder Help.
Exercise 37
Create a property class called DATE_CLASS. Set the initial value to the database date Set the format mask Set the background color Set enabled to no Set keyboard navigable to no Set the datatype to type date Set the maximum length to 11
SunGard 2004-2008
Page 222
Oracle Forms 6i