Advanced Oracle PL/SQL Programming with Packages

Advanced Oracle PL/SQL Programming with PackagesSearch this book
Previous: 5.5 PLVcat: PL/SQL Code CataloguingChapter 5
PL/Vision Package Specifications
Next: 5.7 PLVcmt: Commit Processing
 

5.6 PLVchr: Operations on Single Characters

The PLVchr (PL/Vision CHaRacter) package provides information about single characters in a string. See the companion disk for details.

5.6.1 PLVchr constants

blank_char CONSTANT CHAR(1) := ' ';
space_char CONSTANT CHAR(1) := ' ';
quote1_char CONSTANT CHAR(1) := '''';
quote2_char CONSTANT CHAR(2) := '''''';
tab_char CONSTANT CHAR(1) := CHR(9);
newline_char CONSTANT CHAR(1) := CHR(10);

Named constants to use in place of hard-coded literals. Sure, there is more typing involved. But at least you don't have to mess with single quotes, and the code is a lot more readable.

c_nonprinting CONSTANT CHAR(1) := 'n';
c_digit CONSTANT CHAR(1) := '9';
c_letter CONSTANT CHAR(1) := 'a';
c_other CONSTANT CHAR(1) := '*';
c_all CONSTANT CHAR(1) := '%';

Action codes for use in PLVchr programs that allow you to specify the category of character that you want to work with.

5.6.2 Character type functions

FUNCTION is_quote (char_in IN VARCHAR2) RETURN BOOLEAN;
FUNCTION is_blank (char_in IN VARCHAR2) RETURN BOOLEAN;

Functions to encapsulate hard-coded checks for contents of the strings.

FUNCTION is_nonprinting (code_in IN INTEGER) RETURN BOOLEAN;
FUNCTION is_nonprinting (letter_in IN VARCHAR2) RETURN BOOLEAN;

Returns TRUE if the character (or, overloaded as this function is, the ASCII code) is a non-printing character.

FUNCTION is_digit (code_in IN INTEGER) RETURN BOOLEAN;
FUNCTION is_digit (letter_in IN VARCHAR2) RETURN BOOLEAN;

Returns TRUE if the character (or, overloaded as this function is, the ASCII code) is a digit (0 through 9).

FUNCTION is_letter (letter_in IN VARCHAR2) RETURN BOOLEAN;
FUNCTION is_letter (code_in IN INTEGER) RETURN BOOLEAN;

Returns TRUE if the character (or, overloaded as this function is, the ASCII code) is a letter (a-z or A-Z).

FUNCTION is_other (code_in IN INTEGER) RETURN BOOLEAN;
FUNCTION is_other (letter_in IN VARCHAR2) RETURN BOOLEAN;

Returns TRUE if the character (or ASCII code) is not a letter, digit, or nonprinting character.

5.6.3 Other functions and procedures

FUNCTION char_name (letter_in IN VARCHAR2) RETURN VARCHAR2;
FUNCTION char_name (code_in IN INTEGER) RETURN VARCHAR2;

Returns the name of the provided character. This name is actually a standard abbreviation for the character, such as NL for new line. The name of a printable character is simply the character itself. You can pass either a character or an integer code to see the name.

FUNCTION quoted1 (string_in IN VARCHAR2) RETURN VARCHAR2;
FUNCTION quoted2 (string_in IN VARCHAR2) RETURN VARCHAR2;

Each function returns a string wrapped inside the number of single quote marks needed to allow the string to be evaluated to a string surrounded by one and two single quote marks, respectively.

FUNCTION stripped (string_in IN VARCHAR2, char_in IN VARCHAR2)
RETURN VARCHAR2;

Strips a string of all instances of the specified characters. This function is a frontend to TRANSLATE.

PROCEDURE show_string
(string_in IN VARCHAR2, flags_in IN VARCHAR2 := c_all);

Displays the ASCII code and its associated character for each character in the specified string. You can request to view only certain kinds of characters.

PROCEDURE show_table
(start_code_in IN INTEGER := 1,
end_code_in IN INTEGER := NULL);

Displays the ASCII code and its associated character for all codes within the specified start-end range.


Previous: 5.5 PLVcat: PL/SQL Code CataloguingAdvanced Oracle PL/SQL Programming with PackagesNext: 5.7 PLVcmt: Commit Processing
5.5 PLVcat: PL/SQL Code CataloguingBook Index5.7 PLVcmt: Commit Processing

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
This HTML Help has been published using the chm2web software.