Chapter 18 Test Your Thinking

Team-Fly    

Oracle® PL/SQL® Interactive Workbook, Second Edition
By Benjamin Rosenzweig, Elena Silvestrova
Table of Contents
Chapter 18.  Collections


In this chapter, you learned about collections and multilevel collections. Here are some projects that will help you test the depth of your understanding.

1)

Create the following script. Create an index-by table and populate it with the instructor's full name. In other words, each row of the index-by table should contain first name, middle initial, and last name. Display this information on the screen.

2)

Modify the script created in 1). Instead of using an index-by table, use a varray.

3)

Modify the script created in 2). Create an additional varray and populate it with unique course numbers that each instructor teaches. Display instructor's name and the list of courses he or she teaches.

4)

Find and explain errors in the following script:

 DECLARE     TYPE varray_type1 IS VARRAY(7) OF INTEGER;     TYPE table_type2 IS TABLE OF varray_type1 INDEX BY     BINARY_INTEGER;     varray1 varray_type1 := varray_type1(1, 2, 3);     table2 table_type2 := table_type2(varray1,     varray_type1(8, 9, 0));  BEGIN     DBMS_OUTPUT.PUT_LINE ('table2(1)(2): '||table2(1)(2));  FOR i IN 1..10 LOOP        varray1.EXTEND;        varray1(i) := i;        DBMS_OUTPUT.PUT_LINE ('varray1('||i||'): '||           varray1(i));     END LOOP;  END; 

The projects in this section are meant to have you utilize all of the skills that you have acquired throughout this chapter. The answers to these projects can be found in Appendix D and at the companion Web site to this book, located at http://www.phptr.com/rosenzweig2e. Visit the Web site periodically to share and discuss your answers.


    Team-Fly    
    Top
     



    Oracle PL. SQL Interactive Workbook
    Oracle PL/SQL Interactive Workbook (2nd Edition)
    ISBN: 0130473200
    EAN: 2147483647
    Year: 2002
    Pages: 146

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net