Sie sind auf Seite 1von 64

Enhanced Guide to Oracle8i

Chapter 8:
Advanced Form Builder Topics

1
Non-Input Form Items
 Form items that display data but don’t
allow the user to change values
 Boilerplate text and objects
 Display items
 Image items
 Sound items

2
Boilerplate Text and Objects
 Enhance form appearance
 Text
 Captions or other text
 Drawn with Text tool
 Objects
 Circles, rectangles, lines, etc.
 Drawn with tools on tool palette

3
Display Items
 Used to display text data in a text box
that the user cannot change
 Retrieved from database
 Calculated values
 Other text
 Drawn using Display Item tool
 Note: tool text background is gray, not
white

4
Creating Display Items that
Display Calculated Values
 Draw the display item
 Change its Calculate Mode property
 Formula: value specified by a PL/SQL
formula
 Summary: value specified by a summary
operation

5
Displaying Images in Forms
 Static imported images
 Incorporates image into form .fmb file
 Makes .fmb file larger
 Used to display images that are the same on each
form, regardless of data that appears
 Dynamic images
 Loads image data at runtime
 Used to display:
 Images that are retrieved from the database
 Large images that you don’t want to store in the .fmb file

6
Adding a Static Image to a
Form
 Click File, point to Import, click
Image
 Select image file and specify image
properties

7
Static Image Properties
 Image format
 Specifies the image file format and file
extension
 Image quality
 Determines how image data is stored in
Form Builder in terms of resolution and
number of colors
 Values: Excellent, Very Good, Good, Fair, Poor
 “Excellent” stores more data than “Good”

8
Creating a Dynamic Image
 Create an image item on the form using the Image
Item tool
 Create a trigger to load image items into the
database using the READ_IMAGE_FILE procedure

Image
item

Button with
trigger to
load image
9
READ_IMAGE_FILE Procedure
 Syntax:
READ_IMAGE_FILE(filename, ‘file_type’,
‘item_name’);
 Parameters:
 filename: complete folder path and filename
specification of the image file
 file_type: type of image file (TIFF, BMP, etc.)
 item_name: name of image item, in
‘block_name.item_name’ format

10
Using Sound Items in Forms
 Sound data can be stored in Oracle
database BLOB data fields
 You can create a form sound item to
allow users to play sound clips
Slider Volume
bar control
Time
Play indicator
button Fast forward/
Rewind buttons
11
Creating a Sound Item in a
Form
 Create a Sound Item on the form using
the Sound Item tool
 You can also convert the item type to a
Sound Item in the Data Block Wizard in re-
entrant mode
 Load the sound item into the database
from the file system using the
READ_SOUND_FILE procedure
12
The READ_SOUND_FILE
Procedure
 Syntax:
READ_SOUND_FILE(filename,
‘file_type’, ‘item_name’);
 Parameters:
 filename: complete specification of sound clip file
 file_type: supported sound types (AU, AIFF<
AIFF-C, WAVE)
 item_name: name of form sound item, in
‘block_name.item_name’ format

13
Data Block Sources
 Sources for data block data:
 Table
 View
 FROM clause query
 Stored procedure
 Transactional trigger

14
Using Tables as Block Data
Sources
 Enables you to create a data block
based on a single table, or tables with
master-detail relationships
 Allows DML operations
 Allows queries
 Easy to create
 Can be slow when retrieving large
datasets
15
Using Views as Block Data
Sources
 Allows you to seamlessly display data from
multiple tables
 Only allows DML operations on simple views
 Allows queries
 Easy to create
 View must be created as a database object
 Can be slow when retrieving large datasets

16
Using FROM Clauses as Data
Block Sources
 Enables you to create a data block
based on a query that joins multiple
tables
 Does not allow DML operations
 Allows queries
 Avoids having to create a view

17
Using Stored Procedures as
Data Block Sources
 Stored procedure creates a table or –REF
cursor on which the data block is based
 Does not support DML or query operations
 Can provide more complex data displays
 Can incorporate program logic into a data
display
 Can improve performance when retrieving
large datasets

18
Using Transactional Triggers
as Data Block Sources
 Trigger that fires in place of a DML
command on a table
 Can support DML and query operations
 Can be used to create a form based on
a non-Oracle data source
 Requires custom programs to be written
that intercept DML commands

19
Programming Form Key
Operations
 When the user presses a function key
or key combination while a form is
running, a key trigger executes
 Examples of form key operations:
 F1: Commits current form data
 Ctrl + e: Opens an editor for the current
text item

20
Key Triggers
 Examples of Form Builder predefined
key triggers (more in Table 8-4):
Key Sequence Name of Key Associated
Trigger Command
F7 Key-ENTQRY ENTER_QUERY;
F8 Key-EXEQRY EXECUTE_QUERY
F9 Key-LISTVAL LIST_VALUES;
F10 Key-COMMIT COMMIT;
Ctrl + e Key-EDIT EDIT_TEXITEM;

21
Redefining Existing Key
Operations
 Create a key trigger associated with the
existing key sequence trigger event
 Example: to redefine F10, create a Key-
COMMIT trigger
 Specify alternate code in key trigger

22
Oracle Transaction Processing
 Transaction: series of DML commands that
constitute a logical unit of work
 Phases
 Posting
 DB server receives and acknowledges a DML command
 Change is visible to current user, but not to other users
 Committing
 Change is made permanent in the database
 Change is visible to other users

23
Form Builder Transaction
Processing Phases
 Reads records from database and displays
them in the form
 Allows users to make tentative changes
 Posts changes to the database
 Commits changes to the database when:
 User clicks Save button
 User presses F10
 CLEAR_BLOCK or CLEAR_FORM built-in executes
 Users clicks Yes when asked to save changes to
database

24
Form Transaction Triggers
 Triggers used to control transaction
processing and record auditing
information
 Prefixes:
 PRE-: fires just before an event occurs
 POST-: fires just after an event occurs

25
Form Transaction Triggers

Result on User
User Action Triggers Fired
Screen Display
PRE-QUERY
PRE-SELECT
Execute Query POST-SELECT Data appears on form
POST-CHANGE
POST-QUERY
WHEN-NEW-RECORD-INSTANCE
WHEN-NEW-ITEM-INSTANCE

Insert Record WHEN-NEW-RECORD-INSTANCE New blank record appears


WHEN-NEW-ITEM-INSTANCE

POST-CHANGE
WHEN-VALIDATE-RECORD
Save POST-BLOCK Message “FRM-40400:
(new or updated record) PRE-COMMIT Transaction complete:
PRE-INSERT 1 records applied and
POST-INSERT saved” appears
POST-FORMS-COMMIT
POST-DATABASE-COMMIT
26
Form Transaction Triggers
(continued)

User Action Triggers Fired Result on User


Screen Display

Remove Record WHEN-NEW-RECORD-INSTANCE Record data is removed


WHEN-NEW-ITEM-INSTANCE from form

POST-BLOCK
PRE-COMMIT
Save PRE-DELETE Message “FRM-40400:
(after removing record) POST-DELETE Transaction complete:
POST-FORMS-COMMIT 1 records applied and
POST-DATABASE-COMMIT saved” appears

27
Using Forms with Large Data
Sets
 Approaches
 Create indexes on search and join fields
 Encourage users to count query hits before
executing queries
 Limit number of retrieved records by forcing users
to enter search conditions
 Configure LOVs to always allow users to filter data
 Use array processing
 Base retrievals on asynchronous queries

28
Forcing Users to Enter a
Search Condition
 Create a PRE-QUERY trigger that fires when
user does not enter a search condition in a
data block form
 Trigger code:
 Tests to see if user entered a search condition
 If not, advises user to enter search condition
 Abandons current query

29
Code to Test For Search
Condition

30
Configuring LOVs to Handle
Large Retrieval Sets
 An LOV retrieves all records before the
LOV display appears
 Can be slow if many records are retrieved
 An LOV can retrieve a maximum of 32,767
records
 Use the LOV Wizard Advanced page to
configure an LOV to handle large data
sets
31
LOV Wizard Advanced Page

Record group
fetch size

Automatic
refresh

Filter before
display

32
Advanced Page Properties
 Record Group Fetch Size
 Specifies how many records are fetched in
each query processing cycle
 For queries that retrieve large data sets,
make the record group fetch size larger to
speed up processing

33
Advanced Page Properties
 Automatic Refresh
 Specifies whether the LOV queries the
database each time LOV display opens
 When check box is cleared, LOV records
are only retrieved the first time the user
opens the LOV display
 Clear check box for large data sets

34
Advanced Page Properties
 Filter Before Display
 Specifies whether LOV records appear
before user enters a search condition
 When check box is checked, no records
appear in the LOV display until the user
has a chance to enter a search condition
 Check the check box for large data sets

35
Array Processing
 By default, Form Builder processes each record
one at a time
 Array processing allows a group of records to
be processed as a single unit, which speeds up
processing
 To enable DML array processing, change the data
block’s DML Array Size property value to a larger
value
 To enable query array processing, change the data
block’s Query Array Size property to a larger value

36
Enabling Array Processing
 To enable DML array processing:
 Change the data block’s DML Array Size
property value to a larger value
 To enable query array processing:
 Change the data block’s Query Array Size
property to a larger value

37
Asynchronous Queries
 Retrieve and display part of the
retrieved data while the rest of the data
is being retrieved
 To implement in Form Builder:
 Create a data block based on a stored
procedure
 Configure the stored procedure to retrieve
and display records in sets

38
Mouse Operations
 Mouse click triggers: fire when user
clicks a mouse button
 WHEN-MOUSE-DOWN
 WHEN-MOUSE-UP
 WHEN-MOUSE-CLICK
 WHEN-MOUSE-DOUBLECLICK

39
Mouse Operations
 Mouse move triggers: fire when user
moves the mouse pointer across the
screen display
 WHEN-MOUSE-ENTER
 WHEN-MOUSE-LEAVE
 WHEN-MOUSE-MOVE

40
Creating Mouse Triggers
 Can be associated with:
 Form
 Block
 Item
 Trigger fires when user performs the
mouse action when the item associated
with the trigger has the form focus

41
Changing the Mouse Pointer
Appearance
 Syntax:
SET_APPLICATION_PROPERTY
(CURSOR_STYLE, ‘cursor_style’);
 Cursor Style Values:
 DEFAULT
 BUSY
 CROSSHAIR
 HELP
 INSERTION

42
Form Record Groups
 Static
 Contents are specified at design time, and cannot
be changed at runtime
 Query
 Contents are based on a SQL query that executes
while the form is running
 Nonquery
 Contents are inserted programmatically at runtime

43
Creating a Static Record
Group
 Create a new
record group
object
 Specify the values
in the Column
Specification
dialog box

44
Creating a Query Record
Group Manually
 Create a new record group object
 Specify the SQL query that is the record
group source

SQL
query

45
Creating a Query Record
Group Programmatically
 Use the CREATE_GROUP_FROM_QUERY
procedure
 Syntax:
group_id := CREATE_GROUP_FROM_QUERY
(‘record_group_name’, ‘SQL_query_text’,
record_group_scope,
number_of_fetch_records);

46
Record Group Scope
 FORM_SCOPE
 Record group is only visible inside the
current form
 GLOBAL_SCOPE
 Record group is visible to all forms that are
currently running in the current user
session

47
Populating and Deleting
Programmatic Query Record Groups
 Populating the record group:
return_value :=
POPULATE_GROUP(‘record_group_name’);
 Deleting the record group:
DELETE_GROUP(‘record_group_name’);

48
Example Code

49
Nonquery Record Groups
 Contains values that cannot be
retrieved using a SQL query
 Examples:
 Complex calculated values
 Future dates

50
Creating a Nonquery Record
Group
1. Create the record group
2. Define the record group columns
3. Add new blank rows
4. Specify each value in each row

51
Creating a Nonquery Record
Group
 Syntax:
group_id :=
CREATE_GROUP(‘record_group_name’,
record_group_scope,
number_of_fetch_records);

52
Defining Columns in a
Nonquery Record Group
 Syntax:
column_id :=
ADD_GROUP_COLUMN(‘record_group_name’,
‘column_name’,
column_data_type_specification,
column_width);

53
Adding Data Values to a
Nonquery Record Group
 Syntax:
SET_GROUP_datatype_CELL
(‘record_group_name.column_name’,
row_number, value);
 Procedures:
 SET_GROUP_CHAR_CELL
 SET_GROUP_NUMBER_CELL
 SET_GROUP_DATE_CELL

54
Controlling Data Block
Relationships
 In a form that contains a master-detail
relationship, the master and detail block
are coordinated
 Users can perform coordination-causing
events
 Operation that causes the current record in
the detail block to change

55
Relations in Master-Detail
Relationships
 When you create a master-detail
relationship, a relation object is created
in the master block

Master block

Relation
Detail block
56
Important Relation Properties
 Relation Type
 Join: caused by joining 2 key fields
 Ref: created using a REF pointer
 Detail Data Block
 Name of detail block
 Join Condition
 Name of master and detail items on which
blocks are joined

57
More Relation Properties
 Delete Record Behavior
 Specifies how deleting a master record
affects the corresponding detail records
 Values:
 Non Isolated: master block cannot be deleted
when detail records exist
 Isolated: master block can be deleted when
detail records exist
 Cascading: performs a cascading delete

58
More Relation Properties
 Prevent Masterless Operations
 Specifies whether the user can query or
insert records in the detail block when no
master record is present
 Values:
 Yes: detail records cannot be inserted or
queried, and error message appears
 No: detail block can be used independently of
master block to insert and query records

59
More Relation Properties
 Deferred and Automatic Query
 Properties that work together to determine
whether detail block records automatically change
when the user selects a new master record
 Values:
 Deferred = No, Automatic Query = Yes or No: detail
records are fetched automatically
 Deferred = Yes, Automatic Query = Yes: detail records
are not fetched until user navigates to detail block
 Deferred = Yes, Automatic Query = No: detail records
are not fetched until user navigates to detail block and
executes the EXECUTE_QUERY built-in

60
Master-Detail Relationship
Triggers
 When you create a master-detail relationship,
Form Builder creates the following triggers:
 ON-CLEAR-DETAILS
 clears detail block records
 ON-POPULATE-DETAILS
 coordinates values in master and detail blocks
 ON-CHECK-DELETE-MASTER
 prohibits deleting master record when detail records
exist
 PRE-DELETE
 executes cascading delete

61
Master-Detail Relationship
Triggers
 ON-CLEAR-DETAILS and ON-
POPULATE-DETAILS are always present
 ON-CHECK-DELETE-MASTER is only
present when Delete Record value is
Non Isolated
 PRE-DELETE is only present when
Delete Record value is Cascading

62
Master-Detail Program Units
 When you create a master-detail
relationship, Form Builder automatically
creates the following program units:
 CLEAR_ALL_MASTER_DETAILS
 Clears detail records
 QUERY_MASTER_DETAILS
 Fetches detail records
 CHECK_PACKAGE_FAILURE
 Displays error messages as necessary

63
Changing Relation Properties
Programmatically
 Syntax:
SET_RELATION_PROPERTY(‘relation_name’,
property, value);

64

Das könnte Ihnen auch gefallen