Forms Tutorial
Forms Tutorial
What Is Developer/2000?
Developer/2000 is an Oracle tool that helps you to create forms and reports based on the
tables that you have created using Designer/2000. You can use Developer/2000 to:
● Design and customize your forms and reports.
● Add various functionality, like radio buttons, combo boxes, and list of values to
make your forms and reports more user friendly.
● Write triggers on your objects to add functionality to them and capture errors.
Tools Provided By Oracle Developer/2000
Oracle Developer/2000 provides four tools:
● Object Navigator: In this tool you can view all your objects, add new objects and
name/rename your objects.
● Layout Editor: This tool helps you design your forms and reports and add various
objects to them like push buttons and list boxes.
● PL/SQL Editor: This is the tool that is used to write all the codes for the triggers,
procedures or functions.
● Menu Editor: This tool will help you create a customized menu that can be
attached to your form or report.
Logging On to Developer/2000
1. To log on to Developer/2000, go to Start Developer R2.1 and select Form
Builder (See Figure 8.1)
Page 1 of 37
Oracle Forms
8.2)
Page 2 of 37
Oracle Forms
Page 3 of 37
Oracle Forms
Page 4 of 37
Oracle Forms
Figure 8.8: The window with the list of tables in the database
10. You will now see your selected table and its available columns on your
screen. Click on the single right arrow to select the first column to be shown in
your form; in this case the STUDID column. You will now see this column under
the database items selected sub-window. (See Figure 8.9)
Figure 8.9: The window with the selected table and its available columns.
11. To move the rest of the columns, simply click on the double right arrow
and this will select all your columns in to the database items. (See Figure 8.10)
Page 5 of 37
Oracle Forms
Figure 8.10: The Database Wizard Window with all the selected columns of
the base table
12. You will now see the Congratulations window. Make sure that "Create the
data block, then call the Layout Wizard" is selected and click on Finish. (See
Figure 8.11)
Page 6 of 37
Oracle Forms
Figure 8.13: The window displaying the height and width of the items
selected
15. The Layout Wizard will now prompt you to select the layout or view style
of your block. Select Form and click Next. (See Figure 8.14)
Page 7 of 37
Oracle Forms
Figure 8.14: The window for selecting the layout style of the selected table
16. The Layout Wizard will now prompt you to select a title for the form that
you are creating. Type in Student Records. Click Next to continue. (See Figure
8.15)
Figure 8.15: The Window for selecting the appropriate title for the Form
17. Congratulations! You have now successfully created your first form. Click
Finish to view your form. (See Figure 8.16)
Page 8 of 37
Oracle Forms
Page 9 of 37
Oracle Forms
19. You can now format the form manually. Click on the frame to select it.
Then drag the frame to make it bigger. (See Figure 8.18)
Page 10 of 37
Oracle Forms
21. After you have formatted all the data fields, your form should look like
Figure 8.20.
3. Now type in the following statement to insert more data into the Major_list table:
SQL> INSERT INTO MAJOR_LIST VALUES ('Accounting');
Page 11 of 37
Oracle Forms
4. Now, type in Select * from Major_List to view your newly created table and its
records. (See Figure 9.1)
Page 12 of 37
Oracle Forms
Figure 9.4: The New LOV Window with the select code
select major into :studblock.major from major_list order by major;
8. Once you click OK, you will come back to the Object navigator window. Now,
name the LOV as MAJOR_LOV by double clicking the word LOV. (See Figure
9.5)
Page 13 of 37
Oracle Forms
Page 14 of 37
Oracle Forms
Figure 9.7: Creating a push button to place it beside the Major data field
11. After the push button has been created, then right click on the button and
select Property Palette from the list that pops up. (See Figure 9.8)
Page 15 of 37
Oracle Forms
Page 16 of 37
Oracle Forms
Figure 9.10: The Canvas View with the Push Button for the LOV
14. Now back in the canvas, right click on push and this time select the
PL/SQL Editor. (See Figure 9.11)
Page 17 of 37
Oracle Forms
15. In the PL/SQL Editor we will write a trigger that will connect this button
to the table called Major_List, so that when the user clicks on the button they will
be able to view the list of options. When you select the Pl/SQL Editor, the
window for the new trigger selection will appear. (See Figure 9.12)
Figure 9.12: The Window with the list of triggers available to the user
16. We will write a When-Button-Pressed trigger, since we would like the
code to be activated when the user presses the button. Scroll down and select
When-Button-pressed trigger. (See Figure 9.13)
Page 18 of 37
Oracle Forms
Declare
Return_LOV Boolean;
Begin
Return_LOV :=show_LOV('Major_LOV');
End;
Figure 9.15: The Window for the PL/SQL Editor with the code for the LOV
19. To test how the button works, you can view the form by returning to the
Canvas View and selecting Run Form from the Program menu. (See Figure 9.16)
Page 19 of 37
Oracle Forms
Page 20 of 37
Oracle Forms
Figure 9.18: Selecting the Property Palette for the FTPT_Status field
23. Change the item type from text to Radio Group and set the initial value to
either FT or PT. Close the Property Palette by clicking the close button on the
upper right hand corner. (See figure 9.19)
Page 21 of 37
Oracle Forms
Figure 9.20: The palette with the icon for the radio buttons
25. Drop the radio button into the canvas. Immediately a window will appear,
prompting you to select the radio group you would like to attach this radio button
to. Select the radio group FTPT_Status. (See Figure 9.21)
Figure 9.21: The Window for Attaching the radio button to a radio group
Page 22 of 37
Oracle Forms
26. Now right click on the radio button and go to its Property Palette. Change
the label of the button to 'Full_Time', change background color to gray and give
the radio button a value of FT. (See Figure 9.22)
Page 23 of 37
Oracle Forms
29. Go to the properties for the rectangle frame by right clicking on it, and
change the fill pattern to none. (See Figure 9.24)
Figure 9.24: Selecting the Property Palette for the rectangle frame
30. Now, click on the rectangle frame and select Format Bevel Lowered to
format the frame. (See Figure 9.25)
Page 24 of 37
Oracle Forms
Figure 9.25: Formatting the Rectangle Frame around the radio buttons
31. You can now test your form by selecting Program Run Form. Your form
with the newly created radio buttons should now look like Figure 9.26.
Figure 9.26: The form with the newly created radio buttons
32. We will now create a drop-down poplist for the variable Start_Sem that
will contain four entries: Fall, Spring, Summer 1 and Summer 2. To do this, go to
the Property Palette for the Start_Sem and change its item type from text to list
items, and select type of list as poplist. (See Figure 9.27). Close the Property
Palette to return to the Canvas View by clicking on the close button in the upper
right hand corner
Page 25 of 37
Oracle Forms
Page 26 of 37
Oracle Forms
Page 27 of 37
Oracle Forms
Figure 9.31: Selecting the Property Palette for the push button
37. Now select the PL/SQL editor by right clicking on the push button. (See
Figure 9.32).
Page 28 of 37
Oracle Forms
Figure 9.32: Selecting the PL/SQL Editor for the push button
38. Select the WHEN-BUTTON-PRESSED-TRIGGER, insert the following
PL/SQL code in the blank space of the editor and then click Compile.
begin
select studid, studname, ftpt_status, sex, start_sem, start_year, major
into :studblock.studid, :studblock.studname, :studblock.ftpt_status,
:studblock.sex, :studblock.start_sem, :studblock.start_year, :studblock.major
from student
where studid = :studblock.studid;
exception
when no_data_found then
message ('Invalid Student Id:Please enter a valid Id.');
raise form_trigger_failure;
end;
39. In the above code, we are writing a select statement for retrieving the
record of a student with any particular student ID. If no data is found on a
particular student ID, then Developer/2000 will give an error message and raise
the form_trigger_failure trigger. Run the form and type in a invalid STUDID to
check the message. (See Figure 9.33)
Page 29 of 37
Oracle Forms
Figure 9.33: Error Message when invalid Student ID is entered by the user
In a similar manner, create two other buttons, totaling three push buttons.
40. Go to the second push button, right click on it and go to its property
palette. Change its label to Insert. Now come back to the Layout Editor, right
click again on the push button and go to its PL/SQL Editor. In it, write the
following code in the When-Button-Pressed trigger:
Commit;
Clear_Form;
41. Label the third push button as Clear. At the When-Button-Pressed Trigger,
write the following code:
Clear_Form;
42. Now go back to the Canvas View and Program Run Form to view your
form with the three push buttons. (See Figure 9.34)
Page 30 of 37
Oracle Forms
Page 31 of 37
Oracle Forms
Creating an Alert
1. Go to Alerts in the Object Navigator and double click on it. (See Figure 10.1)
Page 32 of 37
Oracle Forms
Page 33 of 37
Oracle Forms
Figure 10.6: The PL/SQL Editor window for the new Program Unit
7. In the PL/SQL Editor, type in the following code for activating the alert. You may
have to delete a couple of lines from the Editor to avoid duplication. In this code,
we will declare a number variable called return_alert. We will then set it to show
the alert that we created earlier in this lesson called Delete_Alert. We will then
write a simple if/then statement, such that if the user clicks on OK, which is alert
button 1, then Developer/2000 will perform the deletion and commit the changes.
Otherwise, it will exit the alert window and help the users decide on their action.
(See Figure 10.7 to get a view of the code as it should look in the PL/SQL editor.
Do not forget to compile.)
Page 34 of 37
Oracle Forms
PROCEDURE Display_Delete_Alert IS
return_alert NUMBER;
BEGIN
return_alert := show_alert ('DELETE_ALERT');
if return_alert = alert_button1 then
commit;
else
rollback;
end if;
END;
Page 35 of 37
Oracle Forms
Figure 10.8: Selecting the PL/SQL Editor for the Delete button
9. At the When-Button-Pressed trigger in the PL/SQL Editor, write the following
code:
delete from student where studid = :studblock.studid;
delete_record;
Display_Delete_Alert;
The last line of the code will call the previously created procedure
Display_Delete_Alert and activate the alert whenever the user clicks on the delete
button. The first two lines of code delete the record for any particular student ID.
(See Figure 10.9 to get a view of the alert when the user clicks the delete button).
Page 36 of 37
Oracle Forms
Figure 10.9: The fully functional form with the alert on the Delete button
Page 37 of 37