home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Advanced Oracle PL/SQL Programming with Packages

Advanced Oracle PL/SQL Programming with PackagesSearch this book
Previous: 7.4 Controlling Output from p Chapter 8 Next: 8.2 Displaying PLVtab Tables

8. PLVtab: Easy Access to PL/SQL Tables

The PLVtab (PL/Vision TABle) packag e offers predefined PL/SQL table types and programs to make it easier to declare, use, and display the contents of PL/SQL tables. PL/SQL tables are the closest things to arrays in PL/SQL , but there are a number of complications. First, to use a PL/SQL table, you first have to declare a table type. Then you can declare and use the PL/SQL table itself. Beyond the definition of the PL/SQL table, the fact that it is a sparse, unbounded, homogeneous data structure can lead to complications, particularly when it comes to scanning and displaying those structures (see Chapter 10 of Oracle PL/SQL Programming ).

By using PLVtab, you can avoid (in most cases) having to define your own PL/SQL table types. You can also take advantage of flexible, powerful display procedures to view table contents.

When you display the contents of PL/SQL tables, PLVtab allows you to:

  • Show or suppress a header for the table

  • Show or suppress the row numbers for the table values

  • Display a prefix before each row of the table

This chapter shows how to use the different aspects of PLVtab.

8.1 Using PLVtab-Based PL/SQL Table Types

When you use PL/SQL tables, you normally perform a number of common actions, including defining the table type, declaring the table, filling up the rows, referencing the rows, and emptying the table when done. When using a PLVtab-based table, you do not have to declare the table type. Instead you simply reference the package-based type in your declaration. PLVtab predefines the following PL/SQL table TYPEs, shown in Table 8.1 :

Table 8.1: Table Types Predefined in PLVtab




PL/SQL table of Booleans


PL/SQL table of dates


PL/SQL table of integers


PL/SQL table of numbers


PL/SQL table of VARCHAR2(30) strings


PL/SQL table of VARCHAR2(60) strings


PL/SQL table of VARCHAR2(80) strings


PL/SQL table of VARCHAR2(2000) strings


PL/SQL table of VARCHAR2(100) strings; matches PLV.plsql_identifier declaration.


PL/SQL table of VARCHAR2(32767) strings

Let's compare the "native" and PL/Vision approaches to defining PL/SQL tables. In the following anonymous block, I define a PL/SQL table of Booleans without the assistance of PLVtab .

   TYPE bool_tabtype IS TABLE OF BOOLEAN
   yesno_tab bool_tabtype;

With the PLVtab package in place, all I have to is the following:

   yesno_tab PLVtab.boolean_table;

Once you have declared a table using PLVtab, you manipulate that table as you would a table based on your own table TYPE statement.

Previous: 7.4 Controlling Output from p Advanced Oracle PL/SQL Programming with Packages Next: 8.2 Displaying PLVtab Tables
7.4 Controlling Output from p Book Index 8.2 Displaying PLVtab Tables

The Oracle Library Navigation

Copyright (c) 2000 O'Reilly & Associates. All rights reserved.

Library Home Oracle PL/SQL Programming, 2nd. Ed. Guide to Oracle 8i Features Oracle Built-in Packages Advanced PL/SQL Programming with Packages Oracle Web Applications Oracle PL/SQL Language Pocket Reference Oracle PL/SQL Built-ins Pocket Reference