Previous
Previous
 
Next
Next

Creating a Master Detail Form

A master detail form reflects a one-to-many relationship between two tables in a database. Typically, a master detail form displays a master row and multiple detail rows within a single HTML form. With this form, users can insert, update, and delete values from two tables or views.

Topics:

About Master Detail Forms

When running a master detail form, data is rendered as a report using various form elements (including text fields, text areas, date pickers, select lists, radio groups, and so on).

Description of rprt_master_detail.gif follows
Description of the illustration rprt_master_detail.gif

By default, date columns are created using the Date Picker item type. If user interface defaults are defined, other columns can be automatically created as select lists based on lists of values, or numeric fields and large text areas.

Click Create to add a new row. Click the Edit icon to edit row details.

Description of rprt_master_detail2.gif follows
Description of the illustration rprt_master_detail2.gif

On the Master Detail, the master record displays as a standard form and the detail records display in a tabular form at the bottom of the page.


See Also:

"Managing User Interface Defaults" in Oracle Application Express SQL Workshop Guide

For numeric and date fields, you can also pre-define date and number format masks, or apply those format masks after generating the initial form. Wizard generated master detail forms also automatically create validations for some columns. Validations are created for columns that are set to NOT NULL in the underlying table and columns of type NUMBER, DATE or TIMESTAMP. Note that validations are not created for columns if the column is set to read-only, either based on the user's selection, or defined user interface defaults.


Tip:

You can control the appearance of a specific column by editing column attributes. See "Altering Classic Report Layout Using Column Attributes" and "Editing SQL and Classic Reports".

Creating a Master Details form Using the Create Application Wizard

The Create Application Wizard is designed to quickly create a basic Oracle Application Express application consisting of multiple pages and components. This wizard uses general best practices to generate the application and does not include several advanced options included in the Create Page Wizard.

To create a tabular form using the Create Application Wizard:

  1. On the Workspace home page, click the Application Builder icon.

  2. Click the Create button.

  3. For Application Type, select Database.

  4. For Method, select From Scratch.

  5. For Name, enter the following and click Next:

    1. Name - Enter a name to identify the application.

    2. Application - Enter a unique integer value to identify the application.

    3. Create Application - Select a creation method:

      • Select From scratch to manually add all pages

      • Select Based on existing application design model to copy page definitions from a previous application model.

        Note that you will still have to define all other application attributes, or you can choose to copy some attributes by choosing to copy shared components from another application (See step 11).

    4. Schema - Your application will obtain its privileges by parsing all SQL as a specific database schema. Identify the database schema owner.

    Next, select a page type and table on which to build the tabular form.

  6. For Pages:

    1. Select Page Type - Select Master Detail.

    2. Master Table Name - Select a table.

      This table will be used to create a report page and used as the master form on the master detail page.

    3. Detail Table Name - Select a table.

      Only tables and views that are associated to your selected Master Table via a foreign key are displayed.

    4. Click Add Page.

      The new page appears at the top of the page.

    5. Click Next.

  7. On Tabs, specify a tab implementation and click Next.

  8. For Shared Components, determine whether to import shared components from another application. Shared components are common elements that can display or be applied on any page within an application.

    To include shared components, select the following:

    1. Copy Shared Components from Another Application - Select Yes.

    2. Copy from Application - Select the application from which you want to import shared components.

    3. Select Components to Import - Select the components to import.

    4. Click Next.

    Next, select a default authentication scheme. Authentication is the process of establishing a user's identity before they can access an application. See "Establishing User Identity Through Authentication".

  9. For Authentication Scheme, select one of the following:

    • Application Express - Uses the user account credentials created and maintained with the Application Express Service Administration application. These are the accounts you use to log in to the Application Express development environment. You can also create accounts in this user account repository for end users of your applications.

    • No Authentication - Also known as database authentication, this option enables users to access your application using the account credentials stored in the modplsql DAD definition. In most cases this results in users not having to login when accessing your application. This is the quickest way to create a “public” application.

    • Database Account - Requires users logging into your application to enter a database schema name (or user name) and a password in order to authenticate. This account information is managed entirely within the Oracle database.

  10. Next, specify the following attributes:

    1. Language - Select the primary language for this application.

      This attribute identifies the language in which an application is developed. This language is the base language from which all translations are made.

    2. User Language Preference Derived From - Specifies how the engine determines the application language. The application primary language can be static (that is, derived from the Web browser language) or determined from a user preference or item. The database language setting determines date display and sorting characteristics.

      You can alter the Language and User Language Preference Derived From attributes later on the Edit Globalization attributes page. See "Configuring Globalization Attributes".

    3. Date Format - Specifies the date format to be used in the application.

      This date format is used to alter the NLS_DATE_FORMAT database session setting before showing or submitting any page within the application. This value can be a literal string containing a valid Oracle date format mask or an item reference via substitution syntax. If no value is specified, the default date format is derived from the database session at runtime. If supplied, this is also used as the date format for any items resulting from columns of type DATE.

    4. Click Next.

  11. For User Interface, select a theme and click Next.

    Themes are collections of templates that can be used to define the layout and style of an entire application. See "Managing Themes".

  12. Confirm your selections and click Create.

Create a Master Detail Form Using the Create Page Wizard

The Create Page Wizard provides support for creating a master detail from two tables that do not have foreign key relationship defined in the database. Although Oracle recommends the use of foreign keys and properly defined relationships in the underlying database, developers do not always have the ability to modify their database model.

When created using a wizard, the master form on a master detail form page includes buttons that enable the user to move forward and backward with in the master result set. While running the wizard, you choose which columns determine the navigation order. You also have the option to choose whether to create a two-page or three-page master detail form, with the detail records shown in a report with single-record editing on a separate page.

To create a master detail form using the Create Page Wizard:

  1. On the Workspace home page, click the Application Builder icon.

  2. Select an application.

  3. Click Create Page.

  4. Select Form and click Next.

  5. Select Master Detail Form and click Next.

    The Master Detail Wizard appears.

  6. On Master Table:

    1. Select the table or view owner.

    2. Select a table or view name.

      The columns in that object appear under Available Columns.

    3. Select the columns to display in the form and then click the arrow keys to move them to Displayed Columns.

    4. Click Next.

  7. On Detail Table:

    1. Specify whether to show only related tables by selecting Yes or No.

    2. Select the table or view owner.

    3. Select a table or view name.

      The columns in that object appear under Available Columns.

    4. Select the columns to display in the form and then click the arrow keys to move them to Displayed Columns.

    5. Click Next.

  8. On Primary Key Source, select the primary key column for the master table and click Next. Then select the primary key column for the detail table and click Next. Options include:

    • Existing trigger - Select this option if a trigger is defined to populate the primary key, or if the user will be expected to enter the primary key value manually. Detail tables do not support user entered primary key values.

    • Custom PL/SQL function - Select this option if you want to provide a PL/SQL function to populate the primary key.

    • Existing sequence - Select this option if an existing sequence will be used to generate the primary key.

  9. On Master Options, specify whether to include master row navigation and click Next.

    If you include master row navigation, define navigation order columns. If a navigation order column is not defined, the master update form navigates by the primary key column.

  10. On Layout, specify how to build the master detail and click Next. Options include:

    • Edit detail as tabular form on same page creates a two page master detail. Edit detail on separate page creates a three page master detail.

    • Edit detail on separate page creates a three page master detail.

  11. On Page Attributes, review and edit the master page and detail page information and then click Next.

  12. On Tab, specify whether to include a tab set and click Next.

  13. Click Create.