Advanced Oracle PL/SQL Programming with Packages

Advanced Oracle PL/SQL Programming with PackagesSearch this book
Previous: 7.1 Using the l ProcedureChapter 7
p: A Powerful Substitute for DBMS_OUTPUT
Next: 7.3 The Output Prefix
 

7.2 The Line Separator

When you compile and store code in SQL*Plus, any blank lines in your source code are discarded. This annoying "undocumented feature" wreaks havoc at compile time. If there are any compile errors, the line number stored in USER_ERRORS and returned by SHOW ERRORS almost never matches the line number of the code in your operating system file. What an annoyance!

The situation gets even worse when you really want to preserve those blank lines for readability. The PLVhlp package, for example, provides an architecture for online help. Without blank lines in the help text, it would be very difficult to make this text understandable. It would be awfully nice to be able to preserve those blank lines -- or at least make a line appear to be blank when displayed.

The p package recognizes this need and allows you to specify a line separator character. If a line of text passed to p.l consists only of the line separator character, it is displayed as a blank line.

You set the line separator with the set_linesep procedure, whose header is:

PROCEDURE set_linesep (linesep_in IN VARCHAR2);

You can retrieve the current line separator character with the linesep function:

FUNCTION linesep RETURN VARCHAR2;

The default line separator character is =. As a result, if I execute the following anonymous block,

BEGIN
   p.l ('this');
   p.l ('=');
   p.l ('is');
   p.l ('=');
   p.l ('separated!');
END;
/

I see this output:

this

is

separated!


Previous: 7.1 Using the l ProcedureAdvanced Oracle PL/SQL Programming with PackagesNext: 7.3 The Output Prefix
7.1 Using the l ProcedureBook Index7.3 The Output Prefix

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