3.3. Default Values

Your task is to create applications for your users, but those applications should also be easy to use for your clients. One of the ways you can help your users is to make it possible for them to skip data entry for any fields that will usually have the same value. You can specify a default value for these situations.

Try It Out: Default Values

A good candidate for a default value in the sample application is the ORDER_TIMESTAMP column, which would normally be the date the order is entered.

  1. Return to the main development page for the application and select the master-detail page you created for ORDERS and ORDER_ITEMS, which would be the first page labeled Order Items, Page 4 if you are following along.

Rather than drill down to the detail page, you can use the Edit Link to go directly to the field from the runtime environment.

  1. Run the page by clicking on the Run icon.

  2. Click on the Edit Link for the Order Timestamp field, which is below the field.

  3. Click the Default button to show the section of the page attributes related to default values, as shown in its completed form in Figure 3-11.

    Figure 3-11. Figure 3-11
  4. Enter SYSDATE in the Default Value text box, and change the Default Value Type to PL/SQL Expression.

SYSDATE is a function you can use with Oracle SQL or PL/SQL to return the current system date.

  1. Click Apply Changes.

While you are making changes for this ...

Get Beginning Oracle® Application Express now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.