1 Package body ecx_Conditions as
2 -- $Header: ECXCONDB.pls 120.3 2006/05/24 16:07:11 susaha ship $
3
4 l_procedure PLS_INTEGER := ecx_debug.g_procedure;
5 l_statement PLS_INTEGER := ecx_debug.g_statement;
6 l_unexpected PLS_INTEGER := ecx_debug.g_unexpected;
7 l_procedureEnabled boolean := ecx_debug.g_procedureEnabled;
8 l_statementEnabled boolean := ecx_debug.g_statementEnabled;
9 l_unexpectedEnabled boolean := ecx_debug.g_unexpectedEnabled;
10
11 function check_type_condition
12 (
13 type in varchar2,
14 variable in varchar2,
15 vartype in pls_integer,
16 value in varchar2,
17 valtype in pls_integer
18 ) return boolean
19 is
20
21 i_method_name varchar2(2000) := 'ecx_conditions.check_type_condition';
22 i_rnum number;
23 i_lnum number;
24 i_rdate date;
25 i_ldate date;
26
27 begin
28 if (l_procedureEnabled) then
29 ecx_debug.push(i_method_name);
30 end if;
31
32 if(l_statementEnabled) then
33 ecx_debug.log(l_statement,'type',type,i_method_name);
34 ecx_debug.log(l_statement,'variable',variable,i_method_name);
35 ecx_debug.log(l_statement,'vartype',vartype,i_method_name);
36 ecx_debug.log(l_statement,'value',value,i_method_name);
37 ecx_debug.log(l_statement,'valtype',valtype,i_method_name);
38 end if;
39 if type not in ('0','1','2','3','4','5','6','7')
40 then
41 ecx_debug.setErrorInfo(1, 30, 'ECX_UNSUPPORTED_CONDITION_TYPE', 'TYPE', type);
42 if(l_statementEnabled) then
43 ecx_debug.log(l_statement, 'ECX', 'ECX_UNSUPPORTED_CONDITION_TYPE', i_method_name,
44 'TYPE', type);
45 end if;
46 if (l_procedureEnabled) then
47 ecx_debug.pop(i_method_name);
48 end if;
49 return false;
50 end if;
51
52 -- null
53 if type = '6'
54 then
55 if variable is NULL
56 then
57 if(l_statementEnabled) then
58 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
59 end if;
60 if (l_procedureEnabled) then
61 ecx_debug.pop(i_method_name);
62 end if;
63 return true;
64 else
65 if(l_statementEnabled) then
66 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
67 end if;
68 if (l_procedureEnabled) then
69 ecx_debug.pop(i_method_name);
70 end if;
71 return false;
72 end if;
73 -- Not null
74 elsif type = '7'
75 then
76 if variable is not null
77 then
78 if(l_statementEnabled) then
79 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
80 end if;
81 if (l_procedureEnabled) then
82 ecx_debug.pop(i_method_name);
83 end if;
84 return true;
85 else
86 if(l_statementEnabled) then
87 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
88 end if;
89 if (l_procedureEnabled) then
90 ecx_debug.pop(i_method_name);
91 end if;
92 return false;
93 end if;
94 end if;
95
96 /** String Comparisons **/
97 if ( vartype = 1 or valtype = 1)
98 then
99 -- Equal
100 if type = '0'
101 then
102 if variable = value
103 then
104 if(l_statementEnabled) then
105 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
106 end if;
107 if (l_procedureEnabled) then
108 ecx_debug.pop(i_method_name);
109 end if;
110 return true;
111 else
112 if(l_statementEnabled) then
113 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
114 end if;
115 if (l_procedureEnabled) then
116 ecx_debug.pop(i_method_name);
117 end if;
118 return false;
119 end if;
120
121 -- Not Equal
122 elsif type = '1'
123 then
124 if ( ( variable is null) or ( value is null) or (variable <> value ) )
125 then
126 if(l_statementEnabled) then
127 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
128 end if;
129 if (l_procedureEnabled) then
130 ecx_debug.pop(i_method_name);
131 end if;
132 return true;
133 else
134 if(l_statementEnabled) then
135 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
136 end if;
137 if (l_procedureEnabled) then
138 ecx_debug.pop(i_method_name);
139 end if;
140 return false;
141 end if;
142
143 -- Grater Than
144 elsif type = '2'
145 then
146 if variable > value
147 then
148 if(l_statementEnabled) then
149 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
150 end if;
151 if (l_procedureEnabled) then
152 ecx_debug.pop(i_method_name);
153 end if;
154 return true;
155 else
156 if(l_statementEnabled) then
157 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
158 end if;
159 if (l_procedureEnabled) then
160 ecx_debug.pop(i_method_name);
161 end if;
162 return false;
163 end if;
164 -- Less Than
165 elsif type = '3'
166 then
167 if variable < value
168 then
169 if(l_statementEnabled) then
170 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
171 end if;
172 if (l_procedureEnabled) then
173 ecx_debug.pop(i_method_name);
174 end if;
175 return true;
176 else
177 if(l_statementEnabled) then
178 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
179 end if;
180 if (l_procedureEnabled) then
181 ecx_debug.pop(i_method_name);
182 end if;
183 return false;
184 end if;
185
186 -- Greater than or Equal To
187 elsif type = '4'
188 then
189 if variable >= value
190 then
191 if(l_statementEnabled) then
192 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
193 end if;
194 if (l_procedureEnabled) then
195 ecx_debug.pop(i_method_name);
196 end if;
197 return true;
198 else
199 if(l_statementEnabled) then
200 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
201 end if;
202 if (l_procedureEnabled) then
203 ecx_debug.pop(i_method_name);
204 end if;
205 return false;
206 end if;
207
208 -- Less than or Equal To
209 elsif type = '5'
210 then
211 if variable <= value
212 then
213 if(l_statementEnabled) then
214 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
215 end if;
216 if (l_procedureEnabled) then
217 ecx_debug.pop(i_method_name);
218 end if;
219 return true;
220 else
221 if(l_statementEnabled) then
222 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
223 end if;
224 if (l_procedureEnabled) then
225 ecx_debug.pop(i_method_name);
226 end if;
227 return false;
228 end if;
229 else
230 ecx_debug.setErrorInfo(1, 30, 'ECX_UNSUPPORTED_STRING_CONDITION');
231 if(l_statementEnabled) then
232 ecx_debug.log(l_statement, 'ECX', 'ECX_UNSUPPORTED_STRING_CONDITION',i_method_name);
233 end if;
234 raise ecx_utils.program_exit;
235 end if;
236
237 /** Number Comparisons **/
238 elsif ( vartype = 2 and valtype = 2)
239 then
240 begin
241 i_rnum := variable;
242 i_lnum := value;
243 exception
244 when others then
245 ecx_debug.setErrorInfo(1, 30, 'ECX_CANNOT_CONVERT_TO_NUMBER');
246 if(l_unexpectedEnabled) then
247 ecx_debug.log(l_unexpected, 'ECX', 'ECX_CANNOT_CONVERT_TO_NUMBER', i_method_name);
248 end if;
249 raise ecx_utils.program_exit;
250 end;
251
252 -- Equal
253 if type = '0'
254 then
255 if i_rnum = i_lnum
256 then
257 if(l_statementEnabled) then
258 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
259 end if;
260 if (l_procedureEnabled) then
261 ecx_debug.pop(i_method_name);
262 end if;
263 return true;
264 end if;
265
266 -- Not Equal
267 elsif type = '1'
268 then
269 if ( i_rnum is null) or ( i_lnum is null ) or (i_rnum <> i_lnum)
270 then
271 if(l_statementEnabled) then
272 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
273 end if;
274 if (l_procedureEnabled) then
275 ecx_debug.pop(i_method_name);
276 end if;
277 return true;
278 else
279 if(l_statementEnabled) then
280 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
281 end if;
282 if (l_procedureEnabled) then
283 ecx_debug.pop(i_method_name);
284 end if;
285 return false;
286 end if;
287
288 -- Grater Than
289 elsif type = '2'
290 then
291 if i_rnum > i_lnum
292 then
293 if(l_statementEnabled) then
294 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
295 end if;
296 if (l_procedureEnabled) then
297 ecx_debug.pop(i_method_name);
298 end if;
299 return true;
300 else
301 if(l_statementEnabled) then
302 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
303 end if;
304 if (l_procedureEnabled) then
305 ecx_debug.pop(i_method_name);
306 end if;
307 return false;
308 end if;
309 -- Less Than
310 elsif type = '3'
311 then
312 if i_rnum < i_lnum
313 then
314 if(l_statementEnabled) then
315 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
316 end if;
317 if (l_procedureEnabled) then
318 ecx_debug.pop(i_method_name);
319 end if;
320 return true;
321 else
322 if(l_statementEnabled) then
323 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
324 end if;
325 if (l_procedureEnabled) then
326 ecx_debug.pop(i_method_name);
327 end if;
328 return false;
329 end if;
330
331 -- Greater than or Equal To
332 elsif type = '4'
333 then
334 if i_rnum >= i_lnum
335 then
336 if(l_statementEnabled) then
337 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
338 end if;
339 if (l_procedureEnabled) then
340 ecx_debug.pop(i_method_name);
341 end if;
342 return true;
343 else
344 if(l_statementEnabled) then
345 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
346 end if;
347 if (l_procedureEnabled) then
348 ecx_debug.pop(i_method_name);
349 end if;
350 return false;
351 end if;
352
353 -- Less than or Equal To
354 elsif type = '5'
355 then
356 if i_rnum <= i_lnum
357 then
358 if(l_statementEnabled) then
359 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
360 end if;
361 if (l_procedureEnabled) then
362 ecx_debug.pop(i_method_name);
363 end if;
364 return true;
365 else
366 if(l_statementEnabled) then
367 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
368 end if;
369 if (l_procedureEnabled) then
370 ecx_debug.pop(i_method_name);
371 end if;
372 return false;
373 end if;
374 else
375 ecx_debug.setErrorInfo (1, 30, 'ECX_UNSUPPORTED_NUMBER_CONDITION');
376 if(l_statementEnabled) then
377 ecx_debug.log(l_statement,'ECX', 'ECX_UNSUPPORTED_NUMBER_CONDITION', i_method_name);
378 end if;
379 raise ecx_utils.program_exit;
380 end if;
381
382 /** Date Comparisons **/
383 elsif ( vartype = 12 and valtype = 12 )
384 then
385 begin
386 i_rdate := to_date(variable,'YYYYMMDD HH24MISS');
387 i_ldate := to_date(value,'YYYYMMDD HH24MISS');
388 exception
389 when others then
390 ecx_debug.setErrorInfo(1, 30, 'ECX_CANNOT_CONVERT_TO_DATE');
391 if(l_unexpectedEnabled) then
392 ecx_debug.log(l_unexpected, 'ECX', 'ECX_CANNOT_CONVERT_TO_DATE', i_method_name);
393 end if;
394 raise ecx_utils.program_exit;
395 end;
396
397 -- Equal
398 if type = '0'
399 then
400 if i_rdate = i_ldate
401 then
402 if(l_statementEnabled) then
403 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
404 end if;
405 if (l_procedureEnabled) then
406 ecx_debug.pop(i_method_name);
407 end if;
408 return true;
409 else
410 if(l_statementEnabled) then
411 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
412 end if;
413 if (l_procedureEnabled) then
414 ecx_debug.pop(i_method_name);
415 end if;
416 return false;
417 end if;
418
419 -- Not Equal
420 elsif type = '1'
421 then
422 if (i_rdate is null ) or (i_ldate is null ) or (i_rdate <> i_ldate)
423 then
424 if(l_statementEnabled) then
425 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
426 end if;
427 if (l_procedureEnabled) then
428 ecx_debug.pop(i_method_name);
429 end if;
430 return true;
431 else
432 if(l_statementEnabled) then
433 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
434 end if;
435 if (l_procedureEnabled) then
436 ecx_debug.pop(i_method_name);
437 end if;
438 return false;
439 end if;
440
441 -- Grater Than
442 elsif type = '2'
443 then
444 if i_rdate > i_ldate
445 then
446 if(l_statementEnabled) then
447 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
448 end if;
449 if (l_procedureEnabled) then
450 ecx_debug.pop(i_method_name);
451 end if;
452 return true;
453 else
454 if(l_statementEnabled) then
455 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
456 end if;
457 if (l_procedureEnabled) then
458 ecx_debug.pop(i_method_name);
459 end if;
460 return false;
461 end if;
462 -- Less Than
463 elsif type = '3'
464 then
465 if i_rdate < i_ldate
466 then
467 if(l_statementEnabled) then
468 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
469 end if;
470 if (l_procedureEnabled) then
471 ecx_debug.pop(i_method_name);
472 end if;
473 return true;
474 else
475 if(l_statementEnabled) then
479 ecx_debug.pop(i_method_name);
476 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
477 end if;
478 if (l_procedureEnabled) then
480 end if;
481 return false;
482 end if;
483
484 -- Greater than or Equal To
485 elsif type = '4'
486 then
487 if i_rdate >= i_ldate
488 then
489 if(l_statementEnabled) then
490 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
491 end if;
492 if (l_procedureEnabled) then
493 ecx_debug.pop(i_method_name);
494 end if;
495 return true;
496 else
497 if(l_statementEnabled) then
498 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
499 end if;
500 if (l_procedureEnabled) then
501 ecx_debug.pop(i_method_name);
502 end if;
503 return false;
504 end if;
505
506 -- Less than or Equal To
507 elsif type = '5'
508 then
509 if i_rdate <= i_ldate
510 then
511 if(l_statementEnabled) then
512 ecx_debug.log(l_statement, 'Condition','TRUE', i_method_name);
513 end if;
514 if (l_procedureEnabled) then
515 ecx_debug.pop(i_method_name);
516 end if;
517 return true;
518 else
519 if(l_statementEnabled) then
520 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
521 end if;
522 if (l_procedureEnabled) then
523 ecx_debug.pop(i_method_name);
524 end if;
525 return false;
526 end if;
527 else
528 ecx_debug.setErrorInfo(1, 30, 'ECX_UNSUPPORTED_DATE_CONDITION');
529 if(l_statementEnabled) then
530 ecx_debug.log(l_statement, 'ECX', 'ECX_UNSUPPORTED_DATE_CONDITION', i_method_name);
531 end if;
532 raise ecx_utils.program_exit;
533 end if;
534
535 end if; --- end for the datatype comparisons
536
537 if(l_statementEnabled) then
538 ecx_debug.log(l_statement, 'Condition','FALSE', i_method_name);
539 end if;
540 if (l_procedureEnabled) then
541 ecx_debug.pop(i_method_name);
542 end if;
543 return false;
544
545 if (l_procedureEnabled) then
546 ecx_debug.pop(i_method_name);
547 end if;
548 exception
549 when ecx_utils.program_exit then
550 if (l_procedureEnabled) then
551 ecx_debug.pop(i_method_name);
552 end if;
553 raise ecx_utils.program_exit;
554 when others then
555 ecx_debug.setErrorInfo(2, 30, SQLERRM);
556 if (l_procedureEnabled) then
557 ecx_debug.pop(i_method_name);
558 end if;
559 raise ecx_utils.program_exit;
560 end check_type_condition;
561
562 function check_condition
563 (
564 type in varchar2, -- AND,OR
565 type1 in varchar2, --- =,!=,>,<,>=,<=,null,not null
566 variable1 in varchar2,
567 vartype1 in pls_integer,
568 value1 in varchar2,
569 valtype1 in pls_integer,
570 type2 in varchar2,
571 variable2 in varchar2,
572 vartype2 in pls_integer,
573 value2 in varchar2,
574 valtype2 in pls_integer
575 ) return boolean
576 is
577
578
579 i_method_name varchar2(2000) := 'ecx_conditions.check_condition';
580
581 i_condition boolean :=false;
582 i_condition1 boolean :=false;
583 i_condition2 boolean :=false;
584 begin
585 if (l_procedureEnabled) then
586 ecx_debug.push(i_method_name);
587 end if;
588
589 if(l_statementEnabled) then
590 ecx_debug.log(l_statement,'type',type,i_method_name);
591 ecx_debug.log(l_statement,'type1',type1,i_method_name);
592 ecx_debug.log(l_statement,'variable1',variable1,i_method_name);
593 ecx_debug.log(l_statement,'vartype1',vartype1,i_method_name);
594 ecx_debug.log(l_statement,'value1',value1,i_method_name);
595 ecx_debug.log(l_statement,'valtype1',valtype1,i_method_name);
596 ecx_debug.log(l_statement,'type2',type2,i_method_name);
597 ecx_debug.log(l_statement,'variable2',variable2,i_method_name);
598 ecx_debug.log(l_statement,'vartype2',vartype2,i_method_name);
599 ecx_debug.log(l_statement,'value2',value2,i_method_name);
600 ecx_debug.log(l_statement,'valtype2',valtype2,i_method_name);
601 end if;
602
603 if type1 is null
604 then
605 if (l_procedureEnabled) then
606 ecx_debug.pop(i_method_name);
607 end if;
608 return false;
609 end if;
610
611 if type1 is not null
612 then
613 i_condition1 := check_type_condition(type1,variable1,vartype1,value1,valtype1);
614 end if;
615
616 if type is not null
617 then
618
619 if type not in ('AND','OR')
620 then
621 ecx_debug.setErrorInfo(1, 30, 'ECX_UNSUPPORTED_CONDITION_TYPE', 'TYPE', type);
622 if(l_statementEnabled) then
623 ecx_debug.log(l_statement,'ECX', 'ECX_UNSUPPORTED_CONDITION_TYPE',i_method_name,
624 'TYPE', type);
625 end if;
626 if (l_procedureEnabled) then
627 ecx_debug.pop(i_method_name);
628 end if;
629 return false;
630 end if;
631
632 if ( type2 is null )
633 then
634 ecx_debug.setErrorInfo(1, 30, 'ECX_CONDITION_NOT_DEFINED', 'TYPE', type2);
635 if(l_statementEnabled) then
636 ecx_debug.log(l_statement,'ECX', 'ECX_CONDITION_NOT_DEFINED',i_method_name,
637 'TYPE', type2);
638 end if;
639 if (l_procedureEnabled) then
640 ecx_debug.pop(i_method_name);
644
641 end if;
642 return false;
643 end if;
645 i_condition2 := check_type_condition(type2,variable2,vartype2,value2,valtype2);
646
647 if type = 'AND'
648 then
649 if ( i_condition1 and i_condition2 )
650 then
651 if (l_procedureEnabled) then
652 ecx_debug.pop(i_method_name);
653 end if;
654 return true;
655 end if;
656 elsif type = 'OR'
657 then
658 if ( i_condition1 or i_condition2 )
659 then
660 if (l_procedureEnabled) then
661 ecx_debug.pop(i_method_name);
662 end if;
663 return true;
664 end if;
665 else
666 if (l_procedureEnabled) then
667 ecx_debug.pop(i_method_name);
668 end if;
669 return false;
670 end if;
671
672 elsif type1 is not null
673 then
674 if (l_procedureEnabled) then
675 ecx_debug.pop(i_method_name);
676 end if;
677 return i_condition1;
678 end if;
679
680 exception
681 when ecx_utils.program_exit then
682 if (l_procedureEnabled) then
683 ecx_debug.pop(i_method_name);
684 end if;
685 raise ecx_utils.program_exit;
686 when others then
687 ecx_debug.setErrorInfo(2, 30, SQLERRM);
688 if(l_unexpectedEnabled) then
689 ecx_debug.log(l_unexpected, 'ECX', SQLERRM,i_method_name);
690 end if;
691 if (l_procedureEnabled) then
692 ecx_debug.pop(i_method_name);
693 end if;
694 raise ecx_utils.program_exit;
695 if (l_procedureEnabled) then
696 ecx_debug.pop(i_method_name);
697 end if;
698 end check_condition;
699
700 function math_functions
701 (
702 type in varchar2,
703 x in number,
704 y in number
705 )
706 return number
707 is
708
709 i_method_name varchar2(2000) := 'ecx_conditions.math_functions';
710
711 divide_by_zero exception;
712 pragma exception_init(divide_by_zero,-1476);
713 begin
714
715 if (l_procedureEnabled) then
716 ecx_debug.push(i_method_name);
717 end if;
718
719 if(l_statementEnabled) then
720 ecx_debug.log(l_statement,'type',type,i_method_name);
721 ecx_debug.log(l_statement,'x',x,i_method_name);
722 ecx_debug.log(l_statement,'y',y,i_method_name);
723 end if;
724 if type is null
725 then
726 ecx_debug.setErrorInfo(1, 30, 'ECX_MATH_FUNC_NOT_NULL');
727 if (l_procedureEnabled) then
728 ecx_debug.pop(i_method_name);
729 end if;
730
731 raise ecx_utils.program_exit;
732 end if;
733
734 if type not in ('+','-','/','*')
735 then
736 ecx_debug.setErrorInfo(1, 30, 'ECX_UNSUPPORTED_MATH_FUNC');
737 if (l_procedureEnabled) then
738 ecx_debug.pop(i_method_name);
739 end if;
740 raise ecx_utils.program_exit;
741 end if;
742
743 if type = '+'
744 then
745 if(l_statementEnabled) then
746 ecx_debug.log(l_statement,'x+y',x+y,i_method_name);
747 end if;
748 if (l_procedureEnabled) then
749 ecx_debug.pop(i_method_name);
750 end if;
751 return x+y;
752 elsif type = '-'
753 then
754 if(l_statementEnabled) then
755 ecx_debug.log(l_statement,'x-y',x-y,i_method_name);
756 end if;
757 if (l_procedureEnabled) then
758 ecx_debug.pop(i_method_name);
759 end if;
760 return x-y;
761 elsif type = '*'
762 then
763 if(l_statementEnabled) then
764 ecx_debug.log(l_statement,'x*y',x*y,i_method_name);
765 end if;
766 if (l_procedureEnabled) then
767 ecx_debug.pop(i_method_name);
768 end if;
769 return x*y;
770 elsif type = '/'
771 then
772 if(l_statementEnabled) then
773 ecx_debug.log(l_statement,'x/y',x/y,i_method_name);
774 end if;
775 if (l_procedureEnabled) then
776 ecx_debug.pop(i_method_name);
777 end if;
778 return x/y;
779 end if;
780
781 if (l_procedureEnabled) then
782 ecx_debug.pop(i_method_name);
783 end if;
784 exception
785 when divide_by_zero then
786 ecx_debug.setErrorInfo(2, 30, SQLERRM);
787 if(l_unexpectedEnabled) then
788 ecx_debug.log(l_unexpected, 'ECX', SQLERRM,i_method_name);
789 end if;
790 if (l_procedureEnabled) then
791 ecx_debug.pop(i_method_name);
792 end if;
793 raise ecx_utils.program_exit;
794 when others then
795 ecx_debug.setErrorInfo(2, 30, SQLERRM);
796 if (l_procedureEnabled) then
797 ecx_debug.pop(i_method_name);
798 end if;
799 raise ecx_utils.program_exit;
800 end math_functions;
801
802 procedure getLengthForString
803 (
804 i_string in varchar2,
805 i_length OUT NOCOPY pls_integer
806 )
807 is
808
809
810 i_method_name varchar2(2000) := 'ecx_conditions.getLengthForString';
811
812 begin
813 if (l_procedureEnabled) then
814 ecx_debug.push(i_method_name);
815 end if;
816 if(l_statementEnabled) then
817 ecx_debug.log(l_statement,'i_string',i_string,i_method_name);
818 end if;
819 i_length := lengthb(i_string);
820 if(l_statementEnabled) then
821 ecx_debug.log(l_statement,'i_length',i_length,i_method_name);
822 end if;
823 if (l_procedureEnabled) then
824 ecx_debug.pop(i_method_name);
825 end if;
826
827 exception
831 ecx_debug.log(l_unexpected,'ECX', substr(SQLERRM, 1, 200),i_method_name);
828 when others then
829 ecx_debug.setErrorInfo(2, 30, substr(SQLERRM, 1, 200));
830 if(l_unexpectedEnabled) then
832 end if;
833 if (l_procedureEnabled) then
834 ecx_debug.pop(i_method_name);
835 end if;
836 raise ecx_utils.program_exit;
837 end getLengthForString;
838
839 procedure getPositionInString
840 (
841 i_string in varchar2,
842 i_search_string in varchar2,
843 i_start_position in pls_integer,
844 i_occurrence in pls_integer,
845 i_position OUT NOCOPY pls_integer
846 )
847 is
848 i_method_name varchar2(2000) := 'ecx_conditions.getPositionInString';
849 begin
850 if (l_procedureEnabled) then
851 ecx_debug.push(i_method_name);
852 end if;
853 if(l_statementEnabled) then
854 ecx_debug.log(l_statement,'i_string',i_string,i_method_name);
855 ecx_debug.log(l_statement,'i_search_string',i_search_string,i_method_name);
856 ecx_debug.log(l_statement,'i_start_position',i_start_position,i_method_name);
857 ecx_debug.log(l_statement,'i_occurrence',i_occurrence,i_method_name);
858 end if;
859 i_position := instrb(i_string,i_search_string,i_start_position,i_occurrence);
860 if(l_statementEnabled) then
861 ecx_debug.log(l_statement,'i_position',i_position,i_method_name);
862 end if;
863 if (l_procedureEnabled) then
864 ecx_debug.pop(i_method_name);
865 end if;
866 exception
867 when others then
868 ecx_debug.setErrorInfo(2, 30, substr(SQLERRM, 1, 200));
869 if (l_procedureEnabled) then
870 ecx_debug.pop(i_method_name);
871 end if;
872 raise ecx_utils.program_exit;
873 end getPositionInString;
874
875 procedure getSubString
876 (
877 i_string in varchar2,
878 i_start_position in pls_integer,
879 i_length in pls_integer,
880 i_substr OUT NOCOPY varchar2
881 )
882 is
883 i_method_name varchar2(2000) := 'ecx_conditions.getSubString';
884 begin
885 if (l_procedureEnabled) then
886 ecx_debug.push(i_method_name);
887 end if;
888 if(l_statementEnabled) then
889 ecx_debug.log(l_statement,'i_string',i_string,i_method_name);
890 ecx_debug.log(l_statement,'i_start_position',i_start_position,i_method_name);
891 ecx_debug.log(l_statement,'i_length',i_length,i_method_name);
892 end if;
893 i_substr := substrb(i_string,i_start_position,i_length);
894 if(l_statementEnabled) then
895 ecx_debug.log(l_statement,'i_substr',i_substr,i_method_name);
896 end if;
897 if (l_procedureEnabled) then
898 ecx_debug.pop(i_method_name);
899 end if;
900 exception
901 when others then
902 ecx_debug.setErrorInfo(2, 30, substr(SQLERRM,1,200));
903 if (l_procedureEnabled) then
904 ecx_debug.pop(i_method_name);
905 end if;
906 raise ecx_utils.program_exit;
907 end getSubString;
908
909 procedure test
910 is
911 i_method_name varchar2(2000) := 'ecx_conditions.test';
912 i number;
913 y boolean;
914 i_date1 varchar2(200) := '20010101';
915 i_date2 varchar2(200) := '20010102';
916
917 i_dtd_path varchar2(200);
918 begin
919 ecx_utils.i_errbuf :=null;
920 ecx_utils.i_ret_code :=null;
921
922 ecx_utils.getLogDirectory;
923
924 ecx_debug.enable_debug_new(3,ecx_utils.g_logdir,'test_conditions.txt', 'test_conditions.txt');
925
926 if(l_statementEnabled) then
927 ecx_debug.log(l_statement,'testing conditions ',i_method_name);
928 ecx_debug.log(l_statement,'String conditions ',i_method_name);
929 end if;
930 y := ecx_conditions.check_condition(null,'0','veshaal',1,'veshaal',1,null,null,1,null,1);
931 if(l_statementEnabled) then
932 ecx_debug.log(l_statement,'y',y,i_method_name);
933 end if;
934 y := ecx_conditions.check_condition(null,'1','veshaal',1,'1veshaal',1,null,null,1,null,1);
935 if(l_statementEnabled) then
936 ecx_debug.log(l_statement,'y',y,i_method_name);
937 end if;
938 y := ecx_conditions.check_condition(null,'6','3',1,'4',1,null,null,1,null,1);
939 if(l_statementEnabled) then
940 ecx_debug.log(l_statement,'y',y,i_method_name);
941 end if;
942 y := ecx_conditions.check_condition(null,'7','3',1,'4',1,null,null,1,null,1);
943 if(l_statementEnabled) then
944 ecx_debug.log(l_statement,'y',y,i_method_name);
945 end if;
946
947 if(l_statementEnabled) then
948 ecx_debug.log(l_statement,'Number conditions ',i_method_name);
949 end if;
950 y := ecx_conditions.check_condition(null,'0','-10.555',2,'-10.555',2,null,null,2,null,2);
951 if(l_statementEnabled) then
952 ecx_debug.log(l_statement,'y',y,i_method_name);
953 end if;
954 y := ecx_conditions.check_condition(null,'1','-10.555',2,'-10.555',2,null,null,2,null,2);
955 if(l_statementEnabled) then
956 ecx_debug.log(l_statement,'y',y,i_method_name);
957 end if;
958 y := ecx_conditions.check_condition(null,'2','-10.555',2,'-10.555',2,null,null,2,null,2);
959 if(l_statementEnabled) then
960 ecx_debug.log(l_statement,'y',y,i_method_name);
961 end if;
962 y := ecx_conditions.check_condition(null,'3','-.002',2,'-.001',2,null,null,2,null,2);
963 if(l_statementEnabled) then
964 ecx_debug.log(l_statement,'y',y,i_method_name);
965 end if;
966 y := ecx_conditions.check_condition(null,'4','-100',2,'-120',2,null,null,2,null,2);
967 if(l_statementEnabled) then
968 ecx_debug.log(l_statement,'y',y,i_method_name);
969 end if;
970 y := ecx_conditions.check_condition(null,'5','-100',2,'-110.5',2,null,null,2,null,2);
971 if(l_statementEnabled) then
975 if(l_statementEnabled) then
972 ecx_debug.log(l_statement,'y',y,i_method_name);
973 end if;
974 y := ecx_conditions.check_condition(null,'6','3',2,'4',2,null,null,2,null,2);
976 ecx_debug.log(l_statement,'y',y,i_method_name);
977 end if;
978 y := ecx_conditions.check_condition(null,'7','3',2,'4',2,null,null,2,null,2);
979 if(l_statementEnabled) then
980 ecx_debug.log(l_statement,'y',y,i_method_name);
981 end if;
982
983 if(l_statementEnabled) then
984 ecx_debug.log(l_statement,'Date conditions ',i_method_name);
985 end if;
986 y := ecx_conditions.check_condition(null,'0',i_date1,12,i_date2,12,null,null,12,null,12);
987 if(l_statementEnabled) then
988 ecx_debug.log(l_statement,'y',y,i_method_name);
989 end if;
990 y := ecx_conditions.check_condition(null,'1',i_date1,12,i_date2,12,null,null,12,null,12);
991 if(l_statementEnabled) then
992 ecx_debug.log(l_statement,'y',y,i_method_name);
993 end if;
994 y := ecx_conditions.check_condition(null,'2',i_date1,12,i_date2,12,null,null,12,null,12);
995 if(l_statementEnabled) then
996 ecx_debug.log(l_statement,'y',y,i_method_name);
997 end if;
998 y := ecx_conditions.check_condition(null,'3',i_date1,12,i_date2,12,null,null,12,null,12);
999 if(l_statementEnabled) then
1000 ecx_debug.log(l_statement,'y',y,i_method_name);
1001 end if;
1002 y := ecx_conditions.check_condition(null,'4',i_date1,12,i_date2,12,null,null,12,null,12);
1003 if(l_statementEnabled) then
1004 ecx_debug.log(l_statement,'y',y,i_method_name);
1005 end if;
1006 y := ecx_conditions.check_condition(null,'5',i_date1,12,i_date2,12,null,null,12,null,12);
1007 if(l_statementEnabled) then
1008 ecx_debug.log(l_statement,'y',y,i_method_name);
1009 end if;
1010 y := ecx_conditions.check_condition(null,'6',i_date1,12,i_date2,12,null,null,12,null,12);
1011 if(l_statementEnabled) then
1012 ecx_debug.log(l_statement,'y',y,i_method_name);
1013 end if;
1014 y := ecx_conditions.check_condition(null,'7',i_date1,12,i_date2,12,null,null,12,null,12);
1015 if(l_statementEnabled) then
1016 ecx_debug.log(l_statement,'y',y,i_method_name);
1017 end if;
1018
1019 if(l_statementEnabled) then
1020 ecx_debug.log(l_statement,'testing length procedure',i_method_name);
1021 end if;
1022 ecx_conditions.getlengthforString('htihgoitrhogirtoigtroighoirhgoitirgoitrh',i);
1023 if(l_statementEnabled) then
1024 ecx_debug.log(l_statement,'i',i,i_method_name);
1025 end if;
1026
1027 ecx_conditions.getlengthforString(null,i);
1028 if(l_statementEnabled) then
1029 ecx_debug.log(l_statement,'i',i,i_method_name);
1030 end if;
1031
1032 if(l_statementEnabled) then
1033 ecx_debug.log(l_statement,'testing instrb procedure',i_method_name);
1034 end if;
1035 ecx_conditions.getpositioninString('htihgoitrhogirtoigtroighoirhgoitirgoitrh','hg',1,1,i);
1036 if(l_statementEnabled) then
1037 ecx_debug.log(l_statement,'i',i,i_method_name);
1038 end if;
1039 ecx_conditions.getpositioninString('htihgoitrhogirtoigtroighoirhgoitirgoitrh','hg',1,2,i);
1040 if(l_statementEnabled) then
1041 ecx_debug.log(l_statement,'i',i,i_method_name);
1042 end if;
1043 ecx_conditions.getpositioninString('htihgoitrhogirtoigtroighoirhgoitirgoitrh',null,1,2,i);
1044 if(l_statementEnabled) then
1045 ecx_debug.log(l_statement,'i',i,i_method_name);
1046 end if;
1047
1048 if(l_statementEnabled) then
1049 ecx_debug.log(l_statement,'testing substrb procedure',i_method_name);
1050 end if;
1051 ecx_conditions.getsubstring('htihgoitrhogirtoigtroighoirhgoitirgoitrh',1,20,i_date1);
1052 if(l_statementEnabled) then
1053 ecx_debug.log(l_statement,'i_date1',i_date1,i_method_name);
1054 end if;
1055 ecx_conditions.getsubstring('htihgoitrhogirtoigtroighoirhgoitirgoitrh',1,null,i_date1);
1056 if(l_statementEnabled) then
1057 ecx_debug.log(l_statement,'i_date1',i_date1,i_method_name);
1058 end if;
1059 ecx_conditions.getsubstring('htihgoitrhogirtoigtroighoirhgoitirgoitrh',null,null,i_date1);
1060 if(l_statementEnabled) then
1061 ecx_debug.log(l_statement,'i_date1',i_date1,i_method_name);
1062 end if;
1063
1064 if(l_statementEnabled) then
1065 ecx_debug.log(l_statement,'testing math functions',i_method_name);
1066 end if;
1067 i := ecx_conditions.math_functions('+',1,null);
1068 if(l_statementEnabled) then
1069 ecx_debug.log(l_statement,'i',i,i_method_name);
1070 end if;
1071 i := ecx_conditions.math_functions('-',1,2);
1072 if(l_statementEnabled) then
1073 ecx_debug.log(l_statement,'i',i,i_method_name);
1074 end if;
1075 i := ecx_conditions.math_functions('*',1,2);
1076 if(l_statementEnabled) then
1077 ecx_debug.log(l_statement,'i',i,i_method_name);
1078 end if;
1079 i := ecx_conditions.math_functions('/',1,0);
1080 if(l_statementEnabled) then
1081 ecx_debug.log(l_statement,'i',i,i_method_name);
1082 end if;
1083 i := ecx_conditions.math_functions('6',1,2);
1084 if(l_statementEnabled) then
1085 ecx_debug.log(l_statement,'i',i,i_method_name);
1086 end if;
1087
1088 ecx_debug.print_log;
1089 ecx_debug.disable_debug;
1090 exception
1091 when others then
1092 if(l_unexpectedEnabled) then
1093 ecx_debug.log(l_unexpected,'i_errbuf',ecx_utils.i_errbuf,i_method_name);
1094 ecx_debug.log(l_unexpected,'i_retcode',ecx_utils.i_ret_code,i_method_name);
1095 end if;
1096 ecx_debug.print_log;
1097 ecx_debug.disable_debug;
1098 end test;
1099
1100 end ecx_conditions;