8.7. Implementing PLVtab.display

I faced several challenges when building the display procedures:

  • I had to create a separate procedure for each of the different table types, but I did not want to actually have separate display engines for each table type; the code would be very cumbersome and lengthy. Yet consolidating this code would also be difficult since each display procedure drew its information from a different PL/SQL table.

  • With the implementation of PL/SQL tables prior to Release 2.3 of PL/SQL, it is impossible to obtain information about the state of a PL/SQL table from the runtime engine. Instead, you must keep track of the rows that have been used or be ready to handle the NO_DATA_FOUND exception.

I took care of the code redundancy problem by creating a single internal display procedure (idisplay) that is called by each of the public display procedures. Here is an example of the full body of the display procedure for date tables:

PROCEDURE display 
      (tab_in IN date_table, 
       end_in IN INTEGER,
       hdr_in IN VARCHAR2 := NULL,
       start_in IN INTEGER := 1,
       failure_threshold_in IN INTEGER := 0,
       increment_in IN INTEGER := +1)
   IS
   BEGIN
      idate := tab_in;
      idisplay
        (c_date, end_in, hdr_in, start_in, 
         failure_threshold_in, increment_in);
      idate := empty_date;
   END;

What is going on here? First, I copy the incoming table into a private PL/SQL table (idate). Then I display the contents of the idate table and not the user's table. Finally, I empty the internal PL/SQL table to minimize memory ...

Get Advanced Oracle PL/SQL Programming with Packages 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.