Page 371
NOTE |
The code shown in this listing and figure is available for viewing in the .fmb file, which is on the CD-ROM. You can open the entire form and refer to all the objects and properties there. |
Listing 13.1. Query used to create a new LOV for Course_ID.
select Course_ID from Course where Department_ID = :Department.Department_ID order by Course_ID
Figure 13.24.
Creating a new LOV
for Course_ID.
NOTE |
When you need to reference a block item in an SQL or PL/SQL state- ment, use the syntax :block.item. |
Looking at the object nodes with the Object Navigator, you'll notice that there are two new objects: an LOV named LOV15 and a record group named LOV15. Please realize that you might see different default names given to these objects. To change the name of the record group, select the record group with the mouse and left-click it once more. The name will become blue, and the pointer will become an insertion point. Name the record group COURSE_ID_RG, and name the LOV COURSE_ID_LOV as shown in Figure 13.25.
Page 372
Figure 13.25.
Renaming the LOV
and record group.
You'll want to modify a property of COURSE_ID_LOV. To do this, select COURSE_ID_LOV and right-click Properties. Scroll down until you reach the Column Mapping property. Click the button labeled More at the top of the Properties window (see Figure 13.26).
Figure 13.26.
Modifying the
properties of an LOV.
The LOV Column Mapping window will appear. There are four fields in this window. The Column Names field identifies the columns that are returned by the record group's query. The Return Item field is used to specify the block item in which the current value in the Column Names field is to be deposited. The Display Width field indicates the width of the field as displayed in the LOV. Finally, the Column Title field holds the title that will be displayed when the LOV is invoked.
Page 373
As displayed in Figure 13.27, enter Course_ID in the Return Item field; this will cause the Course_ID selected the user to be placed in the Course_ID item. Increase the Display Width to 55 points so that the LOV heading for Course_ID isn't truncated. Change the Column Title to Course ID. Click OK for these changes to take effect.
Figure 13.27.
Modifying the
Column Mapping
property of an LOV.
However, there are a few more steps that you need to perform before the LOV is actually used in the form.
Let's test out the modified form.
Page 374
Figure 13.28.
Modifying the Course_IDitem
properties to use the
LOV.
Figure 13.29.
Displaying the LOV
for Course_ID.
Page 375
Scroll down to course 189 and press Enter; you will see 189 in the Course_ID item. If you enter a course that doesn't exist for this department, such as 1234, and press Tab to navigate to the next item, the form will display the LOV and also display a message in the message line stating FRM-40212: Invalid value for field COURSE_ID (see Figure 13.30).
Figure 13.30.
LOV enforces valid
values for
COURSE_ID.
NOTE |
Even if you don't use an LOV for validation, the Oracle database still enforces referential integrity. However, the advantage of an LOV is that it provides a set of legal values so the user doesn't have to remember what values can be entered in an item. |
Before you complete this lesson, save this form as Department_Class.fmb by selecting
File | Save as from the menu.
In this lesson, you learned the following:
Page 376
On Day 14, "Developer/2000: Application Development with Oracle Forms," you learn how to construct a menu, add items to a block to display derived information, create form-level, block-level, and item-level triggers, and call a form from another form and pass a parameter to the invoked form.
Q Can a master-detail form consist of more than one detail block?
A Yes. You simply create each detail block that you want and identify the master block in the Master/Detail tab.
Q Is it possible for several LOVs to reference the same record group?
A Yes. There is no restriction requiring each LOV to have its own record group.
Q Can a form have multiple windows and Canvas-Views?
A Yes, a single form can have multiple windows and Canvas-Views. However, as you will see in the next lesson, it usually makes more sense to create a multiple form application in which each form has a single Canvas-View and window.
The purpose of the Workshop is to allow you to test your knowledge of the material discussed in the lesson. See if you can correctly answer the questions in the quiz and complete the exercises before you continue with tomorrow's lesson.