1 package DBMS_ASSERT AUTHID CURRENT_USER is
2
3 -- Predefined exceptions
4
5 INVALID_SCHEMA_NAME exception;
6 pragma EXCEPTION_INIT(INVALID_SCHEMA_NAME, -44001);
7 INVALID_OBJECT_NAME exception;
8 pragma EXCEPTION_INIT(INVALID_OBJECT_NAME, -44002);
9 INVALID_SQL_NAME exception;
10 pragma EXCEPTION_INIT(INVALID_SQL_NAME, -44003);
11 INVALID_QUALIFIED_SQL_NAME exception;
12 pragma EXCEPTION_INIT(INVALID_QUALIFIED_SQL_NAME, -44004);
13
14 --
15 -- NOOP.
16 --
17 -- This function returns the value without any checking.
18 --
19
20 function NOOP(Str varchar2 CHARACTER SET ANY_CS)
21 return varchar2 CHARACTER SET Str%CHARSET;
22
23 function NOOP(Str clob CHARACTER SET ANY_CS)
24 return clob CHARACTER SET Str%CHARSET;
25
26 --
27 -- SIMPLE_SQL_NAME
28 --
29 -- Verify that the input string is a simple SQL name:
30 -- 1. The name must begin with an alphabetic character.
31 -- 2. It may contain alphanumeric characters as well as
32 -- the characters _, $, and # in the second and subsequent
33 -- character positions.
34 -- 3. Quoted SQL names are also allowed.
35 -- 4. Quoted names must be enclosed in double quotes.
36 -- 5. Quoted names allow any characters between the quotes.
37 -- 6. Quotes inside the name are represented by two quote
38 -- characters in a row, e.g. "a name with "" inside"
39 -- is a valid quoted name.
40 -- 7. The input parameter may have any number of leading
41 -- and/or trailing white space characters.
42 --
43 -- Note: The length of the name is not checked.
44 --
45 -- EXCEPTIONS:
46 -- ORA-44003: string is not a simple SQL name
47
48 function SIMPLE_SQL_NAME(Str varchar2 CHARACTER SET ANY_CS)
49 return varchar2 CHARACTER SET Str%CHARSET;
50
51 --
52 -- QUALIFIED_SQL_NAME
53 --
54 -- Verify that the input string is a qualified SQL name.
55 -- A qualified SQL name <qualified name> can be expressed by the
56 -- following grammar:
57 --
58 -- <local qualified name> ::= <simple name> {'.' <simple name>}
59 -- <database link name> ::= <local qualified name> ['@' <connection string>]
60 -- <connection string> ::= <simple name>
61 -- <qualified name> ::= <local qualified name> ['@' <database link name>]
62
63 --
64 -- EXCEPTIONS:
65 -- ORA-44004: string is not a qualified SQL name
66
67 function QUALIFIED_SQL_NAME(Str varchar2 CHARACTER SET ANY_CS)
68 return varchar2 CHARACTER SET Str%CHARSET;
69
70 --
71 -- SCHEMA_NAME
72 --
73 -- This function verifies that the input string is an existing
74 -- schema name.
75 -- Note:
76 -- Please be aware that by definition, a schema name need not
77 -- be just a simple sql name. For example, "FIRST LAST" is a valid
78 -- schema name. As a consequence, care must be taken to quote the
79 -- output of schema name before concatenating it with SQL text.
80 --
81 -- EXCEPTIONS:
82 -- ORA-44001: Invalid schema name
83
84 function SCHEMA_NAME(Str varchar2 CHARACTER SET ANY_CS)
85 return varchar2 CHARACTER SET Str%CHARSET;
86
87 --
88 -- SQL_OBJECT_NAME
89 --
90 -- This function verifies that the input parameter string
91 -- is a qualified SQL identifier of an existing SQL object.
92 --
93 -- EXCEPTIONS:
94 -- ORA-44002: Invalid object name
95
96 function SQL_OBJECT_NAME(Str varchar2 CHARACTER SET ANY_CS)
97 return varchar2 CHARACTER SET Str%CHARSET;
98
99 --
100 -- ENQUOTE_NAME
101 --
102 -- This function encloses a name in double quotes. No additional
103 -- quotes are added if the name was already in quotes. Verify that
104 -- the resulting quoted identifier is a legal quoted identifier
105 -- as defined by SQL.
106 -- Str (IN) - string to enquote
107 -- capitalize (IN) - if true or defaulted, alphabetic characters of
108 -- Str which were not in quotes are translated to
109 -- upper case.
110
111 function ENQUOTE_NAME(Str varchar2, capitalize boolean default TRUE)
112 return varchar2;
113
114 --
115 -- ENQUOTE_LITERAL
116 --
117 -- Enquote a string literal. Add leading and trailing single quotes
118 -- to a string literal. Verify that all single quotes except leading
119 -- and trailing characters are paired with adjacent single quotes.
120
121 function ENQUOTE_LITERAL(Str varchar2)
122 return varchar2;
123
124 end DBMS_ASSERT;