O'Reilly logo

Advanced Oracle PL/SQL Programming with Packages by Steven Feuerstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12.7. Writing to the Target

The put_line procedure of PLVio writes text to the target repository. Its header is overloaded as follows:

PROCEDURE put_line
   (string_in IN VARCHAR2, line#_in IN INTEGER := NULL);

PROCEDURE put_line (line_in IN line_type);

The first, "string" version of put_line simply bundles the text and line number into a record of type line_type and then calls the second, "record" version of put_line as shown below:

PROCEDURE put_line 
   (string_in IN VARCHAR2, line#_in IN INTEGER := NULL)
IS
   v_line line_type;
BEGIN
   v_line.text := string_in;
   v_line.line# := line#_in;
   put_line (v_line);
END;

Why do I bother with these two versions? To make the package as easy as possible to use. In many situations, you will simply want to take a string and an optional line number and throw it out into the target. You aren't dealing with the more complex aspects of PLVio and therefore have no need for a line record. In this situation, calling the "record version" of put_line becomes a hassle. By writing a few extra lines of code into the package itself, I relieve my users of the burden of declaring a throw-away data structure—the line_type record.

If you plan to build reusable code that will really and truly be reused, you will need to make this kind of extra effort.

The put_line procedure (which from this point on refers to the record version) hides all of the complexity about the current target. You simply tell PLVio that you want to put a line in the target; it worries about the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required