DBA Data[Home] [Help]

PACKAGE: SYS.UTL_CALL_STACK

Source


1 PACKAGE utl_call_stack IS
2 
3   /*
4     Exception: BAD_DEPTH_INDICATOR
5 
6     This exception is raised when a provided depth is out of bounds.
7         - Dynamic and lexical depth are positive integer values.
8         - Error and backtrace depths are non-negative integer values
9         and are zero only in the absence of an exception.
10 
11   */
12   BAD_DEPTH_INDICATOR EXCEPTION;
13     pragma EXCEPTION_INIT(BAD_DEPTH_INDICATOR, -64610);
14 
15   /*
16     Type: UNIT_QUALIFIED_NAME
17 
18     This data structure is a varray whose individual elements are, in order,
19     the unit name, any lexical parents of the subprogram, and the subprogram
20     name.
21 
22     For example, consider the following contrived PL/SQL procedure.
23 
24     > procedure topLevel is
25     >   function localFunction(...) returns varchar2 is
26     >     function innerFunction(...) returns varchar2 is
27     >       begin
28     >         declare
29     >           localVar pls_integer;
30     >         begin
31     >           ... (1)
32     >         end;
33     >       end;
34     >   begin
35     >     ...
36     >   end;
37 
38    The unit qualified name at (1) would be
39 
40    >    ["topLevel", "localFunction", "innerFunction"]
41 
42    Note that the block enclosing (1) does not figure in the unit qualified
43    name.
44 
45    If the unit were an anonymous block, the unit name would be "__anonymous_block"
46 
47   */
48   TYPE UNIT_QUALIFIED_NAME IS VARRAY(256) OF VARCHAR2(32767);
49 
50   /*
51     Function: subprogram
52 
53     Returns the unit-qualified name of the subprogram at the specified dynamic
54     depth.
55 
56     Parameters:
57 
58       dynamic_depth - The depth in the call stack.
59 
60     Returns:
61 
62       The unit-qualified name of the subprogram at the specified dynamic depth.
63 
64     Exception:
65 
66       Raises <BAD_DEPTH_INDICATOR>
67    */
68   FUNCTION subprogram(dynamic_depth IN PLS_INTEGER) RETURN UNIT_QUALIFIED_NAME;
69 
70   /*
71     Function: concatenate_subprogram
72 
73     Convenience function to concatenate a unit-qualified name, a varray, into
74     a varchar2 comprising the names in the unit-qualified name, separated by
75     dots.
76 
77     Parameters:
78 
79       qualified_name - A unit-qualified name.
80 
81     Returns:
82 
83       A string of the form "UNIT.SUBPROGRAM.SUBPROGRAM...LOCAL_SUBPROGRAM".
84 
85    */
86   FUNCTION concatenate_subprogram(qualified_name IN UNIT_QUALIFIED_NAME)
87            RETURN VARCHAR2;
88 
89   /*
90     Function: owner
91 
92     Returns the owner name of the unit of the subprogram at the specified
93     dynamic depth.
94 
95     Parameters:
96 
97       dynamic_depth - The depth in the call stack.
98 
99     Returns:
100 
101       The owner name of the unit of the subprogram at the specified dynamic
102       depth.
103 
104     Exception:
105 
106       Raises <BAD_DEPTH_INDICATOR>.
107    */
108   FUNCTION owner(dynamic_depth IN PLS_INTEGER) RETURN VARCHAR2;
109 
110   /*
111     Function: current_edition
112 
113     Returns the current edition name of the unit of the subprogram at the
114     specified dynamic depth.
115 
116     Parameters:
117 
118       dynamic_depth - The depth in the call stack.
119 
120     Returns:
121 
122       The current edition name of the unit of the subprogram at the specified
123       dynamic depth.
124 
125     Exception:
126 
127       Raises <BAD_DEPTH_INDICATOR>.
128    */
129   FUNCTION current_edition(dynamic_depth IN PLS_INTEGER) RETURN VARCHAR2;
130 
131   /*
132     Function: unit_line
133 
134     Returns the line number of the unit of the subprogram at the specified
135     dynamic depth.
136 
137     Parameters:
138 
139       dynamic_depth - The depth in the call stack.
140 
141     Returns:
142 
143       The line number of the unit of the subprogram at the specified dynamic
144       depth.
145 
146     Exception:
147 
148       Raises <BAD_DEPTH_INDICATOR>.
149    */
150   FUNCTION unit_line(dynamic_depth IN PLS_INTEGER) RETURN PLS_INTEGER;
151 
152   /*
153     Function: dynamic_depth
154 
155     Returns the number of subprograms on the call stack.
156 
157     Parameters:
158 
159     Returns:
160 
161       The number of subprograms on the call stack.
162 
163    */
164   FUNCTION dynamic_depth RETURN PLS_INTEGER;
165 
166   /*
167     Function: lexical_depth
168 
169     Returns the lexical nesting depth of the subprogram at the specified dynamic
170     depth.
171 
172     Parameters:
173 
174       dynamic_depth - The depth in the call stack.
175 
176     Returns:
177 
178       The lexical nesting depth of the subprogram at the specified dynamic
179       depth.
180 
181     Exception:
182 
183       Raises <BAD_DEPTH_INDICATOR>.
184    */
185   FUNCTION lexical_depth(dynamic_depth IN PLS_INTEGER) RETURN PLS_INTEGER;
186 
187   /*
188     Function: error_depth
189 
190     Returns the number of errors on the error stack.
191 
192     Parameters:
193 
194     Returns:
195 
196       The number of errors on the error stack.
197 
198    */
199   FUNCTION error_depth RETURN PLS_INTEGER;
200 
201   /*
202     Function: error_number
203 
204     Returns the error number of the error at the specified error depth.
205 
206     Parameters:
207 
208       error_depth - The depth in the error stack.
209 
210     Returns:
211 
212       The error number of the error at the specified error depth.
213 
214     Exception:
215 
216       Raises <BAD_DEPTH_INDICATOR>.
217    */
218   FUNCTION error_number(error_depth IN PLS_INTEGER) RETURN PLS_INTEGER;
219 
220   /*
221     Function: error_msg
222 
223     Returns the error message of the error at the specified error depth.
224 
225     Parameters:
226 
227       error_depth - The depth in the error stack.
228 
229     Returns:
230 
231       The error message of the error at the specified error depth.
232 
233     Exception:
234 
235       Raises <BAD_DEPTH_INDICATOR>.
236    */
237   FUNCTION error_msg(error_depth IN PLS_INTEGER) RETURN VARCHAR2;
238 
239   /*
240     Function: backtrace_depth
241 
242     Returns the number of backtrace items in the backtrace.
243 
244     Parameters:
245 
246     Returns:
247 
248       The number of backtrace items in the backtrace, zero in the absence of
249       an exception.
250 
251    */
252   FUNCTION backtrace_depth RETURN PLS_INTEGER;
253 
254   /*
255     Function: backtrace_unit
256 
257     Returns the name of the unit at the specified backtrace depth.
258 
259     Parameters:
260 
261       backtrace_depth - The depth in the backtrace.
262 
263     Returns:
264 
265       The name of the unit at the specified backtrace depth.
266 
267     Exception:
268 
269       Raises <BAD_DEPTH_INDICATOR>. Note that backtrace_unit(0); always raises
270       this exception.
271 
272    */
273   FUNCTION backtrace_unit(backtrace_depth IN PLS_INTEGER) RETURN VARCHAR2;
274 
275   /*
276     Function: backtrace_line
277 
278     Returns the line number of the unit at the specified backtrace depth.
279 
280     Parameters:
281 
282       backtrace_depth - The depth in the backtrace.
283 
284     Returns:
285 
286       The line number of the unit at the specified backtrace depth.
287 
288     Exception:
289 
290       Raises <BAD_DEPTH_INDICATOR>. Note that backtrace_line(0); always raises
291       this exception.
292    */
293   FUNCTION backtrace_line(backtrace_depth IN PLS_INTEGER) RETURN PLS_INTEGER;
294 
295 END;