ch05 06


[Chapter 5] 5.6 PLVchr: Operations on Single Characters Chapter 5PL/Vision Package Specifications 5.6 PLVchr: Operations on Single CharactersThe 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.5.5 PLVcat: PL/SQL Code Cataloguing5.7 PLVcmt: Commit Processing Copyright (c) 2000 O'Reilly & Associates. All rights reserved.

Wyszukiwarka

Podobne podstrony:
ch05
ch05(
ch05
ch05
ch05$
ch05
CH05
ch05
ch05
ch05
ch05
ch05
ch05
ch05!
ch05
ch05
ch05

więcej podobnych podstron