-- E --

Using Personal Oracle7 and Oracle Power Objects

Oracle Power Objects is an object-oriented database application development environment that works with Oracle7, a standalone database named Blaze, and SQL Server. Oracle Power Objects is the first Oracle application tool that you can use with a non-Oracle database.



Note

This appendix is based on trial version 1.0 of Oracle Power Objects. The trial version supports only Personal Oracle7 for Windows. However, the current production version of Oracle Power Objects supports all versions of Oracle7.


Using Oracle Power Objects Designer

To build an application with Power Objects, double-click the Power Objects Designer. After you click the OK button on the message box, the Designer opens the Main window and reads any applications, libraries, and database sessions that were opened during the previous Designer session. (See Figure E.1.) The Main window shows a number of sample applications.

Figure E.1. Main window of Power Objects Designer.

Power Objects supports the following three primary object types:

Creating a Database Session

To create a database session, click the electrical plug icon on the toolbar. The Designer displays a dialog box with two input boxes: Database and Connect String. (See Figure E.2.) By default, the Database field is set to oracle. To connect to Personal Oracle, set the Connect String to the Oracle user and password; this example uses frayed_wires/helmholtz. Of course, the Personal Oracle database must be running if you want to establish a database session.

Figure E.2.Creating a database session.

Once you've created a database session, you can save it by clicking the disk icon on the Designer toolbar. The Designer prompts you for the directory and filename to use for saving the current database session. (See Figure F.3.) Don't save your Power Objects objects in the Oracle Power Objects directory tree.

Figure E.3. Saving a database session as a file.



Note

You might not be able to determine an object's type by looking at the Power Objects window. Unless you're displaying an object's property sheet, you might have trouble distinguishing an application from a database session or from a library--;if they all have the same name. You can also have this problem if you're trying to switch to a different window under the Window menu. Therefore, I recommend that you add an appropriate phrase to an object's filename: APP for an application, SES for a database session, and LIB for a library. I hope such a designation won't be necessary in future releases of Power Objects.


After you save a database session, the Designer displays the database session as a disconnected electrical plug in a window labeled with the name of the database session. The database session property sheet is also displayed. (See Figure E.4.)

Figure E.4.Database session icon and property sheet.

To connect to Personal Oracle through the database session, simply double-click the database session icon--;the disconnected electrical plug. The database session uses the Connect String to establish a connection--;in this case, to Personal Oracle. The database session window displays the database session as a connected electrical plug along with all of the database objects that are visible to the specified Oracle user. (See Figure E.5.)

Figure E.5.Connecting to Personal Oracle with the database session.

Creating an Application

To create a new Power Objects application, click the Folder icon on the Designer toolbar. A dialog window appears in which you specify the new application's filename and directory. (See Figure E.6.) In this example the name of the application is rep_app.poa.

Figure E.6.Creating and saving a Power Objects application.

After you specify a filename and directory for the new application, the Designer displays both an empty window (labeled as REP_APP) and the application's property sheet. (See Figure E.7.)

Figure E.7.Power Objects application and property sheet.

Of course, to do anything meaningful with the application, you first need to select a table. To select a table, set the Designer's focus on REP_SESS, the database session, by selecting REP_SESS from the Window menu. Scroll down through the REP_SESS window until you see the Repair_Header table. (See Figure E.8.)

Figure E.8.Selecting a table with the database session.

Double-click the Repair_Header table. The Table Editor window appears with the columns from the Repair_Header table. (See Figure E.9.)

Figure E.9.Using the Power Objects Table Editor.

If you click the lightning-bolt most button on the toolbar, the Table Browser window appears. (See Figure E.10.) When invoked, the Table Browser retrieves the rows from the selected table.

Figure E.10.Retrieving a table's contents with the Table Browser.

While in the Table Browser, you can scroll through the retrieved rows. You can add a new row by clicking the first column of the empty row after the last retrieved row. Figure E.11 illustrates how Power Objects locks a new row by displaying a lock icon to the left of the row.

Figure E.11.Using the Table Browser to insert a row.

When you're finished viewing or changing the contents of the selected table, close the Table Browser by clicking the Stop icon on the toolbar. To restore the REP_APP application, select Window | REP_APP. When the REP_APP window is visible, create a new form by either selecting File | New Form or clicking the New Form icon (to the right of the Scissors icon) on the toolbar. (See Figure E.12.)

Figure E.12.Creating a Power Objects form.

When the new form is created, its property sheet appears. The name of the new form is Form1; to change its name, scroll down the list of properties until you see Name. Click the field to the right of Name and type frmRepair_Header. (See Figure E.13.)

Figure E.13.Specifying the form's name on the property sheet.

To change the form's label, scroll up to the Label property. Type Repair Header in the field to the right of Label. (See Figure E.14.) Keep in mind that you must save your work by either clicking the Save icon or selecting File | Save.

Figure E.14.Specify the form's label on the property sheet.

To bind the form to the table, set the Designer's focus on the Table Browser. Select each column that you want to incorporate in the form by clicking its row. When you've selected all the columns that you want to include, drag the columns and drop them on the form. The Power Objects Designer automatically creates a label for each column. (See Figure E.15.)

Figure E.15. The form generated by the Power Objects Designer.

You'll almost certainly want to modify the generated form. You can improve the appearance of the form by rearranging the fields and resizing the labels. (See Figure E.16.)

Figure E.16. Editing the generated form.

Now add a scrollbar control for navigating through the data. Select the scrollbar, either horizontal or vertical, from the toolbox and drop it on the form. (See Figure E.17.)

Figure E.17. Adding a scrollbar control to a form.

When you're happy with the form's appearance, test the form by clicking the lightning-bolt button on the toolbar. When the form is executed, it retrieves the first row and displays it. (See Figure E.18.) You can scroll through the data with the scrollbar control.

Figure E.18. Running the form.

When you're finished testing the form, click the Stop icon. To practice changing the form's property, scroll down to the OrderBy property on the Repair Header property sheet. Specify Employee_ID for the OrderBy property. (See Figure E.19.) Try running the form again and verify that the rows are retrieved in order by the Employee_ID.

Figure E.19. Changing the form's OrderBy property.

With Power Objects, implementing a master-detail relationship on a form is very simple. You use the repeater object for the detail portion of the form. Select the repeater control from the toolbox--;it's the last icon at the bottom of the right-hand row. Drop it on the bottom of the form. (See Figure E.20.)

Figure E.20. Adding a repeater to the form.

To bind the repeater to the detail table, select the REP_SESS database session by choosing it from the Window menu. Click the Repair_Item table. The Table Browser displays the columns from the Repair_Item table. Select the columns that you want to display in the detail portion of the form. Drag the selected columns onto the repeater and drop them. (See Figure E.21.)

Figure E.21. Dragging the detail columns to the repeater.

Oracle Power Objects automatically places the fields in the repeater. You can improve the appearance of the detail fields by rearranging them within the repeater. To connect the master and detail portions of the form, return to the repeater's property sheet. Scroll down to the LinkDetailColumn property and set it to Repair_ID. Set the LinkMasterColumn property to Repair_ID. This column is a foreign key in the Repair_Item table and a primary key in the Repair_Header table. Set the LinkMasterForm property to frmRepairHeader. (See Figure E.22.) Again, try running the form and verify that the master-detail relationship is functioning properly. (See Figure E.23.)

Figure E.22. Specifying properties for a master-detail relationship.

Figure E.23. Running the master-detail form.