Expert

7-33.

The questions in this section refer to the following tables and types, which implement a rudimentary purchase-order system. The ORDERS table stores a sequential order number along with a short description. The lines of the purchase order are stored in the nested table column ORDER_DETAIL. The TAX_CODES column records the tax codes that apply to the purchase order.

Write a SQL script to create the following structures:

SQL> DESCRIBE orders;
 Name                            Null?    Type
 ------------------------------- -------- ----
 ORDER_NO                        NOT NULL NUMBER
 ORDER_DESC                               VARCHAR2(30)
 ORDER_DETAIL                             ORDER_DETAIL_T
 TAX_CODES                                TAX_CODE_T

SQL> DESCRIBE order_detail_t;
 order_detail_t TABLE OF DETAIL_T
 Name                            Null?    Type
 ------------------------------- -------- ----
 DETAIL_NO                                NUMBER
 DETAIL_DESC                              VARCHAR2(30)
 DETAIL_PRICE                             NUMBER

SQL> DESCRIBE detail_t;
 Name                            Null?    Type
 ------------------------------- -------- ----
 DETAIL_NO                                NUMBER
 DETAIL_DESC                              VARCHAR2(30)
 DETAIL_PRICE                             NUMBER

SQL> DESCRIBE tax_code_t;
 tax_code_t TABLE OF TAX_CODE_DETAIL_T
 Name                            Null?    Type
 ------------------------------- -------- ----
 TAX_CODE                                 VARCHAR2(10)

SQL> DESCRIBE tax_code_detail_t;
 Name                            Null?    Type
 ------------------------------- -------- ----
 TAX_CODE                                 VARCHAR2(10)

SQL> DESCRIBE order_detail;
 Name                            Null?    Type
 ------------------------------- -------- ----
 DETAIL_NO                                NUMBER
 DETAIL_DESC                              VARCHAR2(30)
 DETAIL_PRICE                             NUMBER

SQL> DESCRIBE order_tax_codes;
 Name                            Null?    Type
 ------------------------------- -------- ----
 TAX_CODE                                 VARCHAR2(10)

7-34.

Now that we have the ...

Get Oracle PL/SQL Programming: A Developer's Workbook 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.