@@ -38,6 +38,10 @@ create or replace package body ut_suite_builder is
3838 gc_endcontext constant t_annotation_name := 'endcontext';
3939
4040 gc_placeholder constant varchar2(3) := '\\%';
41+
42+ gc_int_exception constant varchar2(1) := 'I';
43+ gc_name_exception constant varchar2(1) := 'N';
44+ gc_unk_exception constant varchar2(1) := 'U';
4145
4246 --list of annotation texts for a given annotation indexed by annotation position:
4347 --This would hold: ('some', 'other') for a single annotation name recurring in a single procedure example
@@ -192,23 +196,23 @@ create or replace package body ut_suite_builder is
192196 l_c varchar2(250);
193197 l_dblink varchar2(250);
194198 l_next_pos pls_integer;
195- l_exception_type varchar2(50) := 'NUMBER' ;
199+ l_exception_type varchar2(50) := gc_int_exception ;
196200 begin
197201
198202 begin
199- --check if it is a number first
203+ --check if it is a number first
200204 dbms_utility.name_tokenize(a_exception_name, l_a, l_b, l_c, l_dblink, l_next_pos);
201205 --check if it is a predefined exception
202206 begin
203207 execute immediate 'begin null; exception when '||a_exception_name||' then null; end;';
204- l_exception_type := 'NAMED' ;
208+ l_exception_type := gc_name_exception ;
205209 exception
206210 when others then
207211 if dbms_utility.format_error_stack() like '%PLS-00485%' then
208212 execute immediate 'declare x positiven := -('||a_exception_name||'); begin null; end;';
209- l_exception_type := 'NUMBER' ;
213+ l_exception_type := gc_int_exception ;
210214 else
211- l_exception_type := 'UNKNOWN' ;
215+ l_exception_type := gc_unk_exception ;
212216 end if;
213217 end;
214218 exception when others then
@@ -217,31 +221,38 @@ create or replace package body ut_suite_builder is
217221 return l_exception_type;
218222 end;
219223
220-
221- function get_exception_number (a_exception_var in varchar2) return number is
222- l_exception_no number;
223- l_exception_type varchar2(50);
224+ function get_exception_number (a_exception_var in varchar2) return integer is
225+ l_exc_no integer;
226+ l_exc_type varchar2(50);
227+ l_sql varchar2(32767);
228+ function remap_no_data (a_number integer) return integer is
229+ begin
230+ return case a_number when 100 then -1403 else a_number end;
231+ end;
224232 begin
225- l_exception_type := check_exception_type(a_exception_var);
226- if l_exception_type = 'NUMBER' then
227- execute immediate 'declare
228- l_exception number;
229- begin
230- :l_exception := '||a_exception_var||';
231- exception
232- when others then
233- :l_exception := null;
234- end;' using in out l_exception_no;
235-
236- elsif l_exception_type = 'NAMED' then
237- execute immediate 'begin
238- raise '||a_exception_var||';
239- exception
240- when others then
241- :l_exception := sqlcode;
242- end;' using in out l_exception_no;
233+ l_exc_type := check_exception_type(a_exception_var);
234+
235+ if l_exc_type in (gc_int_exception,gc_name_exception) then
236+
237+ execute immediate case l_exc_type
238+ when gc_int_exception then
239+ 'declare
240+ l_exception number;
241+ begin
242+ :l_exception := '||a_exception_var||'; '
243+ when gc_name_exception then
244+ 'begin
245+ raise '||a_exception_var||'; '
246+ end ||
247+ 'exception
248+ when others then
249+ :l_exception := '|| case l_exc_type
250+ when gc_int_exception then 'null;'
251+ when gc_name_exception then 'sqlcode;'
252+ end||'
253+ end;' using in out l_exc_no;
243254 end if;
244- return l_exception_no ;
255+ return remap_no_data(l_exc_no) ;
245256 end;
246257
247258 function is_valid_qualified_name (a_name varchar2) return boolean is
0 commit comments