Master-detail forms display a master row and multiple detail rows within a single HTML page. With this form, users can query, insert, update, and delete values from two tables or views. The tables or views are joined together in the wizard by a SQL JOIN condition.
Values in the master row determine which detail rows are displayed for updating. For example, the master row could display column values from the SCOTT.DEPT table. This table joins to SCOTT.EMP by a column in each table called DEPTNO. Selecting a department ID in the master row displays in detail rows all Employees having the same Department ID.
The end user of the master-detail form can update or delete values in the master row. The wizard provides an option to allow cascading deletes, so that deleting a master row also deletes detail rows. The same master-detail form can be used to insert new detail rows, or update and delete existing detail rows.
Examples
The following is an example of a master-detail form based on the SCOTT.DEPT master table and SCOTT.EMP detail table.
An end user can type a department number, then click the Query button to display all rows in the SCOTT.EMP that match the department number, as shown below.
The end user can then update detail row information, such as adding a Manager for employee named King, then choose Update in the Detail actions list, and click the Save button to save the update in SCOTT.EMP. Multiple detail row and master row updates can performed on a single save.
To insert a new row in SCOTT.EMP, the end user enters the new data in the blank detail row fields at the bottom of the form, chooses Insert in the Detail actions list, then clicks Save.
Note: The user does not have to enter the department number (which is the foreign key that joins the DEPT and EMP tables) for each new row he or she inserts. If the foreign key field is left blank, it is automatically given the value provided in the master row. You can also choose to hide the foreign key completely in the detail rows.
To delete a row, the end user chooses Delete in the Detail actions list next to the row, then clicks Save.