O'Reilly logo

Beginning Oracle® Application Express by Paul Turley, Chris Leiter, Dan Wood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.2. Setting a Variable Default

The first place to use PL/SQL within your application is to set a default value for a new column in the database. You will have to use procedural logic to set this default, since the value of the default changes, depending on the value of fields in the page.

Way back in Chapter 4, you added a default value for the ORDER_TIMESTAMP column. In this section, you will add a new field to the ORDERS table to hold the promised ship date and then create logic to calculate what this ship date should be.

Try It Out: Adding a New Column

Your first task will be to add a new column to the ORDERS table to hold the ship date.

  1. Return to the development environment, and click on the SQL Workshop tab. Bring up the Object Browser by using the cascading menus to browse existing tables.

  2. Click on the ORDERS table to bring up the description of the table.

  3. Click on the Add Column button to begin the creation of a new column for the table with the page shown in Figure 8-1.

  4. Enter ORDER_SHIP_DATE in the Add Column field, make the Type a date, and click Next.

  5. On the next page, click Finish to create the column.

Now that you have a new column in the table, you will have to add an item to the page to display the value.

  1. Click on the Application Builder page, go to the application you are building, and select the master-detail page for the ORDERS and ORDER_ITEMS tables.

  2. In the Items section of the Page Rendering column on the left, click on the plus icon (+) to bring up the page shown ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required