Tutorial for Forms 6i

:
In this lesson you will learn:
   

What is Developer/2000 Tools provided by Developer/2000 to create Forms and Reports How to log on to Developer/2000 Create your first block and form based on your Student table

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 (See Figure 8.1) Developer R2.1 and select Form Builder

Figure 8.1: The Start Menu for Logging in to Developer/2000 2. Immediately, you will see the window for Developer/2000 Form Builder for Windows 95/NT with the sub-window for Welcome to Form Builder. (See Figure 8.2)

Figure 8.2: The Form Builder window 3. Select 'Use the Datablock Wizard' and click OK--This is the easiest method to design a new form. 4. You will now see the Welcome to the Datablock Wizard Window. Click Next to proceed. (See Figure 8.3)

Figure 8.3: Welcome to Datablock Wizard Window 5. You will now see the window for the Datablock Wizard. Select Table or View as in the figure and click Next. (See Figure 8.4)

Figure 8.4: The Datablock Wizard Window

the connect window will appear. click on browse to look at the list of tables and views in your database.6) . Type in your username. (See Figure 8. (See Figure 8.5) Figure 8. You will now see the window that prompts you to select a table or a view--your form will be created based on this selection. Since no table or view is being shown.5: The window for selecting the base table 7. Once you click browse.6. password and database to connect to the database.

) Lesson 8.6: The Connect String Window (We typed "server" in the Database field because our data resides on a central server. Select current users and tables and click OK. You will now see the tables window.Figure 8. (See Figure 8. this field can be blank. page 2 8.7) . If your data resides on your personal hard drive.

8: The window with the list of tables in the database 10.8) Figure 8.Figure 8. You will now see the list of tables created in your database.7: The Tables Window 9. in this case the . Select Students and click OK. (See Figure 8. Click on the single right arrow to select the first column to be shown in your form. You will now see your selected table and its available columns on your screen.

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.9) Figure 8. 11.10) .9: The window with the selected table and its available columns. (See Figure 8. You will now see this column under the database items selected subwindow.STUDID column.

10: The Database Wizard Window with all the selected columns of the base table 12. then call the Layout Wizard" is selected and click on Finish. (See Figure 8.Figure 8. Make sure that "Create the data block. You will now see the Congratulations window.11) .

Click on Next to continue. Make sure that the data block selected is Students and then click the double right arrow to move all the columns of the Student block from the available items to the displayed items. prompting you to select the items that you would like to show in the form.12) .Figure 8. (See Figure 8. You will now see the Layout Wizard.11: The Data Block Wizard Congratulations Window 13.

13: The window displaying the height and width of the items selected . The window with the prompt for the height and width of the items will appear.Figure 8.13) Figure 8. (See Figure 8.12: The Layout Wizard Window 14. Click Next to accept the default values.

page 3 15. The Layout Wizard will now prompt you to select the layout or view style of your block. Type in Student Records.15) . (See Figure 8.14) Figure 8. (See Figure 8. Select Form and click Next. Click Next to continue.14: The window for selecting the layout style of the selected table 16.Lesson 8. The Layout Wizard will now prompt you to select a title for the form that you are creating.

Congratulations! You have now successfully created your first form.Figure 8. Click Finish to view your form.16: The Layout Wizard Congratulations Window .16) Figure 8.15: The Window for selecting the appropriate title for the Form 17. (See Figure 8.

You can now format the form manually.18. You will now see the canvas view of the form that you have created. You can now add various objects like push buttons.18) . We will do this in the next lesson. (See Figure 8. Then drag the frame to make it bigger. combo boxes and radio buttons to your form to make it more graphical and user friendly.17: The canvas view of the newly created form 19.17) Figure 8. Click on the frame to select it. (See Figure 8.

19) . You can now space out the data fields to make your form more visually appealing. (See Figure 8. You can do this by simply selecting the data field and dragging it to your desired area.18: Formatting the size of the frame 20.Figure 8.

Figure 8. your form should look like Figure 8. After you have formatted all the data fields.20. .19: Spacing out the data fields 21.

go to SQL*Plus and type the following code at the SQL prompt SQL> CREATE TABLE MAJOR_LIST 2 (MAJOR VARCHAR2(20)). To do this. . this will involve:      Creating LOVs. we will create a List of Values for major. deleting and retrieving records List of Values (LOVs) 1. first we will have to create table called Major_List. Specifically. so that the user can select a major from the list.Figure 8. or List of Values. 2. where you will connect your form to another table from which the users make their selections Creating Radio Buttons Creating Combo Boxes and Poplists Creating Push Buttons Adding triggers to the Push Buttons for inserting.20: The formatted form Lesson 9 In this lesson you will learn how to create an end-user interface and add more functionality to the basic form that we created in Lesson 8. To do this. In this form we are designing.

2) . First. select LOV in the Object Navigator on Developer/2000 and click on the "+" sign on the toolbar to your left. SQL> INSERT INTO MAJOR_LIST VALUES ('Decision Sciences').1: Creating table Major_List in SQL*PLUS 5. (See Figure 9. Now type in the following statement to insert more data into the Major_list table: SQL> INSERT INTO MAJOR_LIST VALUES ('Accounting'). 4. SQL> INSERT INTO MAJOR_LIST VALUES ('Finance'). type in Select * from Major_List to view your newly created table and its records. Systems').3.1) Figure 9. SQL> INSERT INTO MAJOR_LIST VALUES ('Info. (See Figure 9. SQL> INSERT INTO MAJOR_LIST VALUES ('Marketing'). Now.

(See Figure 9. Immediately.3) Figure 9.2: Creating a new LOV 6. the window for the new LOV will pop up.Figure 9.3: The New LOV Window .

you will come back to the Object navigator window.5) .4) Figure 9. (See figure 9. 8. (See Figure 9. name the LOV as MAJOR_LOV by double clicking the word LOV.4: The New LOV Window with the select code select major into :studblock. Now. Type in the following Select statement in the window to connect the new LOV to the Major_List table that we created earlier and click OK. Once you click OK.7.major from major_list order by major.

5: Changing the name of the LOV 9. Now go back to the Canvas View by clicking on the small picture icon just beneath the word Canvases in the Object Navigator.6) . (See Figure 9.Figure 9.

6: Returning to the Canvas view 10. (See Figure 9. In the Canvas View. To create the push button. we will create a push button and position it right beside the Major data field. select the box like icon from the toolbox.7) . click on it once and drop it beside the Major data field.Figure 9.

After the push button has been created. then right click on the button and select Property Palette from the list that pops up.Figure 9. (See Figure 9.7: Creating a push button to place it beside the Major data field 11.8) .

specify Iconic as Yes and in the icon Filename type Down.Figure 9. Once you are in the Property Palette. (See Figure 9. remove the label.8: Selecting Property Palette for the Push Button 12.9) . Click on the close button in the lower taskbar located on the upper right corner.

Figure 9. Your Canvas will now look like Figure 9.9: The Property Palette for the Push Button 13.10. You will now return to Canvas View. .

right click on push and this time select the PL/SQL Editor.10: The Canvas View with the Push Button for the LOV 14.11) . (See Figure 9. Now back in the canvas.Figure 9.

(See Figure 9. page 2 15. In the PL/SQL Editor we will write a trigger that will connect this button to the table called Major_List.12) . When you select the Pl/SQL Editor.11: Selecting the PL/SQL Editor of the Iconic Button Lesson 9. the window for the new trigger selection will appear.Figure 9. so that when the user clicks on the button they will be able to view the list of options.

(See Figure 9. Scroll down and select When-Button-pressed trigger.13) Figure 9. Type in the following code in the blank space in the Editor.13: Selecting the When-Button-Pressed trigger 17. since we would like the code to be activated when the user presses the button.12: The Window with the list of triggers available to the user 16.Figure 9. Immediately. . We will write a When-Button-Pressed trigger.14). (See Figure 9. you will see the PL/SQL Editor window.

(See Figure 9. After typing in the code. 18.Declare Return_LOV Boolean.14: The PL/SQL Editor window 19. Begin Return_LOV :=show_LOV('Major_LOV'). Figure 9. click compile on the upper left-hand corner of the window.15) . End.

(See Figure 9. you can view the form by returning to the Canvas View and selecting Run Form from the Program menu. To test how the button works.15: The Window for the PL/SQL Editor with the code for the LOV 20.16) .Figure 9.

17). To return to the canvas View. The list of majors will pop up. simply click OK in the list of majors and click the close button in the upper right taskbar.16: Selecting Run Form from the Program menu 21. (See Figure 9. Then click the button with the down arrow. .Figure 9. When the form is running. type in an ID number in the STUDID field (there has to be data in the primary field).

We will now create three push buttons and write triggers for each button. select the button icon from the palette on the left of the canvas and drop in the lower part of the form. To create a push button.30) .17: The List of values for the Majors Lesson 9. page 4 35. (See Figure 9.Figure 9.

(See Figure 9.31). ." To do this. We will change the label of the first push button in the property palette to "Retrieve.30: Selecting a push button 36.Figure 9. right click on the button and go to its Property Palette.

.31: Selecting the Property Palette for the push button 37. Now select the PL/SQL editor by right clicking on the push button.32). (See Figure 9.Figure 9.

major into :studblock. ftpt_status. :studblock. :studblock. :studblock. studname. then Developer/2000 will give an error message and raise the form_trigger_failure trigger. insert the following PL/SQL code in the blank space of the editor and then click Compile. sex.studname. raise form_trigger_failure. If no data is found on a particular student ID.33) . :studblock. Run the form and type in a invalid STUDID to check the message. :studblock. exception when no_data_found then message ('Invalid Student Id:Please enter a valid Id.start_year.major from student where studid = :studblock. start_year. end.').Figure 9. (See Figure 9. 39.32: Selecting the PL/SQL Editor for the push button 38. we are writing a select statement for retrieving the record of a student with any particular student ID. In the above code.sex. :studblock.start_sem.studid.ftpt_status. Select the WHEN-BUTTON-PRESSED-TRIGGER. begin select studid. start_sem.studid.

40.Figure 9. Label the third push button as Clear. create two other buttons. Go to the second push button. At the When-Button-Pressed Trigger. 41. Now come back to the Layout Editor. totaling three push buttons. right click again on the push button and go to its PL/SQL Editor. Change its label to Insert. In it. write the following code in the When-Button-Pressed trigger: Commit.33: Error Message when invalid Student ID is entered by the user In a similar manner. Clear_Form. . write the following code: Clear_Form. right click on it and go to its property palette.

(See Figure 9.1) . you will learn how to:   Create Alerts (a modal window) on a push button that will function as a warning or a message to the users when they click the button. (See Figure 10.42. Go to Alerts in the Object Navigator and double click on it.34: The Form with the three Push buttons Lesson 10 In this lesson. Now go back to the Canvas View and Program three push buttons.34) Run Form to view your form with the Figure 9. Create Procedures which are stored blocks of code which can be called from multiple objects saving the time taken for retyping codes Creating an Alert 1.

In the properties:  Change the title of the alert to Delete Alert  Type in the message as "Are you sure you want to Delete?"  Select Stop as the Alert style  You can add a third button to the alert or just keep the OK and Cancel  Make sure that Button1 is selected as the default button .Figure 10. Now double click on the alert and you will immediately go to its Property Palette.1: Creating a New Alert 2. (See Figure 10. Double click on the newly created alert and name it DELETE_ALERT.2: Changing the name of the new Alert 3.2) Figure 10.

Immediately the window for the new Program unit will appear.(See Figure 10.3: The Property Palette for the Alert 4. we will create a procedure which we will call from the delete button. go to the Object Navigator and double click on Program Units.3) Figure 10. To activate the alert. To add a procedure.4) . (See Figure 10.

(See Figure 10.5) Figure 10. type in the name as Display_Delete-Alert.6) . Once you click OK.4: Creating a new Program Unit 5. Make sure that procedure is selected as the type of Program Unit and click OK. In the window for the new Program Unit.5: Naming the new Program Unit 6. (See Figure 10.Figure 10. you will be automatically taken to the PL/SQL Editor window.

6: The PL/SQL Editor window for the new Program Unit 7. else rollback. (See Figure 10. In this code. if return_alert = alert_button1 then commit. BEGIN return_alert := show_alert ('DELETE_ALERT').) PROCEDURE Display_Delete_Alert IS return_alert NUMBER.7 to get a view of the code as it should look in the PL/SQL editor.Figure 10. We will then set it to show the alert that we created earlier in this lesson called Delete_Alert. type in the following code for activating the alert. it will exit the alert window and help the users decide on their action. we will declare a number variable called return_alert. We will then write a simple if/then statement. Do not forget to compile. Otherwise. end if. END. . which is alert button 1. such that if the user clicks on OK. then Developer/2000 will perform the deletion and commit the changes. In the PL/SQL Editor. You may have to delete a couple of lines from the Editor to avoid duplication.

We will now add a push button to the form and then add the above procedure to it. Now go to its PL/SQL Editor by right clicking on the push button. (See Figure 10.8) . go its properties.7: The code for activating the alert 9.8. go the Layout Editor and add a push button to the form. andchange the label to Delete (use the steps used to create a push button in Lesson 9). the alert will be shown. so that whenever the user clicks on delete. To do this. Figure 10.

write the following code: delete from student where studid = :studblock.studid. (See Figure 10. At the When-Button-Pressed trigger in the PL/SQL Editor. delete_record. 11.Figure 10.8: Selecting the PL/SQL Editor for the Delete button 10. .9 to get a view of the alert when the user clicks the delete button). The first two lines of code delete the record for any particular student ID. 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. Display_Delete_Alert.

12.9: The fully functional form with the alert on the Delete button . Figure 10.

Sign up to vote on this title
UsefulNot useful