Tutorial 3: Master-detail Display and Entry Form Application

Note: We recommend that you print this tutorial for easy reference. To print, click on the right-hand frame before accessing your HTML Browser's File/Print command.

In this tutorial you will build upon the previous application to create an order display and entry form. This will allow you to browse through all the invoices in the database and see the items ordered for each invoice in a table along with the order information. In a master-detail relationship, the master (or driving table) represents the "one" side of a one-to-many relationship, and the detail table is on the "many" side.

In this case, the InvoiceDetail table is related to the Invoice table by the Invoice_Number field. Although the Invoice_Number is enough to relate the InvoiceDetail records to the correct invoice, the Line field, a line number, is required to ensure that each InvoiceDetail record is uniquely specified when updating the table. Both of these fields make up the key for the InvoiceDetail table.

If you saved the .uil file for the Tutorial 2 interface, select Open or Read from the Browser File menu and select the file from the File Selection dialog that is displayed. The interface should look like:

Simple Join Application You Created in Tutorial 2

Creating the Application

Oracle users

  • Because Oracle is case-insensitive, the Schema Browser renders all names uniformly in uppercase.

Adding a table

Use the following steps to add a table to the application shown above.

  • Resize the bulletin board so that there is space below the control panel to add a table (about 2 inches high by the width of the existing interface), as shown:

Existing Interface Resized

  • Select InvoiceDetail from the Tables list in the Schema Browser.
  • Select Table from the Object Type option menu, as shown:

Option Menu Items

Select all columns displayed in the Columns window (because the columns are contiguous, drag through all the columns to select them all at once).
While holding MB2 over the selected columns, drag and drop them onto the empty space on the bulletin board below the Control Panel and on the left side of the bulletin board. Because you selected Table from the Object Type option menu, all the columns you dragged and dropped onto the bulletin board are placed in a table.

Table Added to Application

Setting Resources for the Table

It is necessary to specify a where clause that retrieves all of the Invoice_Detail records for the invoice number currently displayed in the Invoice Number field on the application.

Specifying a where clause

To specify a where clause, use the @value() function within a "where" clause:

1. Locate the dbTable table widget on the Browser, using the Panner or the Select search field.

Table Widget Selected

  • Update the Resource Editor by double-clicking on the dbTable widget in the Browser.
  • Locate the where resource in the Resource Editor.
  • In the input field of the where resource, enter the following: "InvoiceDetail.Invoice_Number = @value(invoice_Invoice_Number)".

This creates a relationship between the dbTable widget and the invoice_Invoice_Number widget. When the value ofinvoice_Invoice_Number changes, it is substituted into the "where" clause of dbTable and the query is re-evaluated.

  • Switch to Play Mode.
  • Press Search. As you move through the records, notice that the table updates to show the invoices associated with the account.

Documentation: