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.
Your first task will be to add a new column to the ORDERS table to hold the ship date.
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.
Click on the ORDERS table to bring up the description of the table.
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.
Enter ORDER_SHIP_DATE in the Add Column field, make the Type a date, and click Next.
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.
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.
In the Items section of the Page Rendering column on the left, click on the plus icon (+) to bring up the page shown ...