Skip to Content
Oracle PL/SQL Programming: A Developer's Workbook
book

Oracle PL/SQL Programming: A Developer's Workbook

by Steven Feuerstein, Andrew Odewahn
May 2000
Intermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Expert

8-33.

All the questions in this section refer to the tables and user-defined datatypes (UDTs) for 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.

As the first exercise in this section, write a SQL script to create the following structures:

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

SQL> DESC order_detail_t
 order_detail_t VARRAY(10) OF DETAIL_T
 Name                            Null?    Type
 ------------------------------- -------- ----
 DETAIL_NO                                NUMBER
 DETAIL_DESC                              VARCHAR2(30)
 DETAIL_PRICE                             NUMBER

SQL> DESC order_detail_nt
 order_detail_nt TABLE OF DETAIL_T
 Name                            Null?    Type
 ------------------------------- -------- ----
 DETAIL_NO                                NUMBER
 DETAIL_DESC                              VARCHAR2(30)
 DETAIL_PRICE                             NUMBER

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

SQL> DESC tax_code_t
 tax_code_t VARRAY(2) OF TAX_CODE_DETAIL_T
 Name                            Null?    Type
 ------------------------------- -------- ----
 TAX_CODE                                 VARCHAR2(10)

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

8-34.

Why were order_detail_t (a variable array) and order_detail_nt (a nested ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle Database 11g PL/SQL Programming Workbook

Oracle Database 11g PL/SQL Programming Workbook

Michael McLaughlin, John Harper

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page