Flylib.com

Books Software

 
 
 

5.24 PLVstk: Stack Manager

advanced oracle pl/sql programming with packages

Chapter 5
PL/Vision Package Specifications
next: 5.25 plvtab: table interface
 

5.24 PLVstk: Stack Manager

The PLVstk (PL/Vision STacK manager) package is a generic manager for both first-in-first-out ( FIFO ) and last-in-last-out ( LIFO ) stacks; it is built on PLVlst. See the companion disk for details.

5.24.1 Package constants

defstk CONSTANT VARCHAR2(5) := 'stack';

The name of the default stack.

lifo CONSTANT VARCHAR2(4) := 'LIFO';

Indicates that you are working with a last-in-first-out stack. Used in calls to pop .

fifo CONSTANT VARCHAR2(4) := 'FIFO';

Indicates that you are working with a first-in-first-out stack. Used in calls to pop .

5.24.2 Creating and destroying stacks

PROCEDURE make
(stack_in IN VARCHAR2 := defstk,
overwrite_in IN BOOLEAN := TRUE);

Allocates storage for a stack of up to 1,000 items with the specified name. By default, if the stack already exists it will be reinitialized to an empty stack.

PROCEDURE destroy (stack_in IN VARCHAR2 := defstk);

Releases all memory associated with this stack.

5.24.3 Modifying stack contents

PROCEDURE push
(item_in IN VARCHAR2, stack_in IN VARCHAR2 := defstk);

Pushes an item onto the specified stack.

PROCEDURE pop
(value_out IN OUT VARCHAR2,
stack_in IN VARCHAR2 := defstk,
stack_type_in IN VARCHAR2 := lifo);

Pops an item off the top ( LIFO ) or bottom ( FIFO ) of the stack.

5.24.4 Analyzing stack contents

FUNCTION nitems (stack_in IN VARCHAR2 := defstk)
RETURN INTEGER;

Returns the number of items currently in the stack.

FUNCTION itemin (stack_in IN VARCHAR2, item_in IN VARCHAR2)
RETURN BOOLEAN;

Returns TRUE if the specified item is found in the stack.

5.24.5 Tracing Stack Activity

PROCEDURE show
(stack_in IN VARCHAR2 := defstk,
show_contents_in IN BOOLEAN := FALSE);

Requests that pre-action status of stack be displayed for the specified stack (or all).

PROCEDURE noshow;

Turns off display of pre-action status.

FUNCTION showing RETURN BOOLEAN;

Returns TRUE if showing pre-action status.

PROCEDURE verify
(stack_in IN VARCHAR2 := defstk,
show_contents_in IN BOOLEAN := FALSE);

Requests that post-action status of stack be displayed for the specified stack (or all).

PROCEDURE noverify;

Turns off display of post-action status.

FUNCTION verifying RETURN BOOLEAN;

Returns TRUE if showing post-action status.


advanced oracle pl/sql programming with packages next: 5.25 plvtab: table interface
5.23 PLVrb: Rollback Processing book index 5.25 PLVtab: Table Interface

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

advanced oracle pl/sql programming with packages

Chapter 5
PL/Vision Package Specifications
next: 5.26 plvtkn: token table interface
 

5.25 PLVtab: Table Interface

The PLVtab (PL/Vision TABle) package makes it easier to declare, use, and display the contents of PL/SQL tables by providing predefined PL/SQL table types and programs. See Chapter 8, PLVtab: Easy Access to PL/SQL Tables for details.

5.25.1 Predefined table TYPEs

Since these table TYPES are already defined in the PLVtab package, you can use them to declare your own PL/SQL tables -- and not deal with the cumbersome syntax.

TYPE boolean_table IS TABLE OF BOOLEAN INDEX BY BINARY_INTEGER; TYPE date_table IS TABLE OF DATE INDEX BY BINARY_INTEGER; TYPE integer_table IS TABLE OF INTEGER INDEX BY BINARY_INTEGER; TYPE number_table IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; TYPE vc30_table IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER; TYPE vc60_table IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER; TYPE vc80_table IS TABLE OF VARCHAR2(80) INDEX BY BINARY_INTEGER; TYPE vc2000_table IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER; TYPE vcmax_table IS TABLE OF VARCHAR2(32767) INDEX BY BINARY_INTEGER;

5.25.2 The empty PL/SQL tables

An empty PL/SQL table is a structure in which no rows have been defined. The only way to delete all the rows from a PL/SQL table is to assign an empty table to that table. You can use these predefined PL/SQL tables to accomplish this task easily.

empty_boolean boolean_table; empty_date date_table; empty_integer integer_table; empty_number number_table; empty_vc30 vc30_table; empty_vc60 vc60_table; empty_vc80 vc80_table; empty_vc2000 vc2000_table; empty_vcmax vcmax_table;

5.25.3 Toggle for showing header

PROCEDURE showhdr;

Requests that a header be displayed with the contents of the table (the header text is passed in the call to the display procedure). This is the default.

PROCEDURE noshowhdr;

Turns off the display of the header text with the table contents.

FUNCTION showing_header RETURN BOOLEAN;

Returns TRUE if the header is being displayed.

5.25.4 Toggle for showing row numbers

PROCEDURE showrow;

Requests that the row number be displayed with the row contents.

PROCEDURE noshowrow;

Turns off display of the row number (the default).

FUNCTION showing_row RETURN BOOLEAN;

Returns TRUE if the row number is being displayed.

5.25.5 Toggle for showing blanks in row

PROCEDURE showblk;

Requests that blank lines be displayed. A NULL row will display as the p.fornull NULL substitution value. A line consisting only of blanks will be displayed as the word BLANKS.

PROCEDURE noshowblk;

Requests that blank lines be displayed as blank lines.

FUNCTION showing_blk RETURN BOOLEAN;

Returns TRUE if showing the contents of blank lines.

5.25.6 Setting the row prefix

PROCEDURE set_prefix (prefix_in IN VARCHAR2 := NULL);

Sets the character(s) used as a prefix to the text displayed before the value in the table's row (default is NULL).

FUNCTION prefix RETURN VARCHAR2;

Returns the current prefix character(s).

5.25.7 Saving and restoring settings

PROCEDURE save;

Saves the current settings for the toggles to private variables in the package.

PROCEDURE restore;

Restores the settings for the toggles from the saved values.

5.25.8 Displaying a PLVtab table

PROCEDURE display
(tab_in IN boolean_tabledate_tablenumber_tableinteger_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);
PROCEDURE display
(tab_in IN
vc30_tablevc60_tablevc80_tablevc2000_tablevcmax_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);

The display procedure is overloaded nine times, for a variety of datatypes. The first version above shows the overloading for non-string datatypes. The second version shows all the different types of string PL/SQL tables supported by the PLVtab.display procedure.


advanced oracle pl/sql programming with packages next: 5.26 plvtkn: token table interface
5.24 PLVstk: Stack Manager book index 5.26 PLVtkn: Token Table Interface

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