DBA Data[Home] [Help]

PACKAGE BODY: APPS.IEM_OPERATORS_PVT

Source


1 PACKAGE BODY IEM_OPERATORS_PVT AS
2 /* $Header: iemvopeb.pls 120.1 2005/06/23 18:15:08 appldev ship $ */
3 --
4 --
5 -- Purpose: Assistant api to Route/Classification/Email Processing Engine.
6 --
7 -- MODIFICATION HISTORY
8 -- Person      Date         Comments
9 --  Liang Xia   5/29/2001  created
10 --  Liang Xia   12/6/2002  Fixed GSCC warning: NOCOPY, no G_MISS ..
11 --  Liang Xia   07/16/2003 Fixed Byte function problem.
12 --  Liang Xia   01/23/2004 Fixed bug: 3389301
13 --  Liang Xia   04/06/2005   Fixed GSCC sql.46 ( bug 4256769 )
14 --  Liang Xia   06/26/2005   Fixed GSCC sql.46 ( bug 4452895 )
15 -- ---------   ------  ------------------------------------------
16 
17 FUNCTION satisfied(leftHandSide IN varchar2, operator IN varchar2, rightHandSide IN varchar2, valueDataType IN varchar2)
18 return boolean is
19 
20 conditionSatisfied  boolean := false;
21 timeFormat          VARCHAR2(20):= 'HH24:MI:SS';
22 dateFormat          VARCHAR2(20):= 'YYYYMMDD';
23 
24 logMessage          VARCHAR2(2000);
25 errorMessage        VARCHAR2(2000);
26 
27 INVALID_DATATYPE    Exception;
28 
29 Begin
30 
31     if( FND_LOG.LEVEL_STATEMENT>= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
32         logMessage := '[' || leftHandSide || operator || rightHandSide || valueDataType || ']';
33         FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT, 'IEM.PLSQL.IEM_OPERATORS_PVT.SATISFIED.KEY_VALS', logMessage);
34     end if;
35 
36 
37     if valueDataType = 'S' then
38         if operator = '=' then
39             if (upper(leftHandSide) = upper(rightHandSide)) then
40                 conditionSatisfied := true;
41                 return conditionSatisfied;
42             end if;
43         elsif operator = '<>' then
44             if (upper(leftHandSide) <> upper(rightHandSide)) then
45                 conditionSatisfied := true;
46                 return conditionSatisfied;
47             end if;
48         elsif operator = 'CONTAINS' then
49             if (instr(upper(leftHandSide), upper(rightHandSide)) <> 0) then
50                 conditionSatisfied := true;
51                 return conditionSatisfied;
52             end if;
53         elsif operator = 'NCONTAINS' then
54             if ( leftHandSide is null or leftHandSide='') then
55                 conditionSatisfied := true;
56                 return conditionSatisfied;
57             elsif (instr(upper(leftHandSide), upper(rightHandSide)) = 0) then
58                 conditionSatisfied := true;
59                 return conditionSatisfied;
60             end if;
61         elsif operator = 'BEGINS' then
62             if (instr(upper(leftHandSide), upper(rightHandSide)) = 1) then
63                 conditionSatisfied := true;
64                 return conditionSatisfied;
65             end if;
66         elsif operator = 'NBEGINS' then
67             if (instr(upper(leftHandSide), upper(rightHandSide)) <> 1) then
68                 conditionSatisfied := true;
69                 return conditionSatisfied;
70             end if;
71                 elsif operator = 'ENDS' then
72             if (upper(substr(leftHandSide, length(rightHandSide) * -1, length(rightHandSide))) = upper(rightHandSide)) then
73                 conditionSatisfied := true;
74                 return conditionSatisfied;
75             end if;
76         elsif operator = 'NENDS' then
77             if (upper(substr(leftHandSide, length(rightHandSide) * -1, length(rightHandSide))) <> upper(rightHandSide)) then
78                 conditionSatisfied := true;
79                 return conditionSatisfied;
80             end if;
81         end if;
82     elsif valueDataType = 'N' then
83         if operator = '=' then
84             if (to_number(leftHandSide) = to_number(rightHandSide)) then
85                 conditionSatisfied := true;
86                 return conditionSatisfied;
87             end if;
88         elsif operator = '<>' then
89             if (to_number(leftHandSide) <> to_number(rightHandSide)) then
90                 conditionSatisfied := true;
91                 return conditionSatisfied;
92             end if;
93         elsif operator = '<' then
94             if (to_number(leftHandSide) < to_number(rightHandSide)) then
95                 conditionSatisfied := true;
96                 return conditionSatisfied;
97             end if;
98         elsif operator = '>' then
99             if (to_number(leftHandSide) > to_number(rightHandSide)) then
100                 conditionSatisfied := true;
101                 return conditionSatisfied;
102             end if;
103         elsif operator = '<=' then
104             if (to_number(leftHandSide) <= to_number(rightHandSide)) then
105                 conditionSatisfied := true;
106                 return conditionSatisfied;
107             end if;
108         elsif operator = '>=' then
109             if (to_number(leftHandSide) >= to_number(rightHandSide)) then
110                 conditionSatisfied := true;
111                 return conditionSatisfied;
112             end if;
113         end if;
114     elsif valueDataType = 'D' then
115         if operator = '=' then
116             if (to_date(leftHandSide, dateFormat) = to_date(rightHandSide, dateFormat)) then
117                 conditionSatisfied := true;
118                 return conditionSatisfied;
119             end if;
120         elsif operator = '<>' then
121             if (to_date(leftHandSide, dateFormat) <> to_date(rightHandSide, dateFormat)) then
122                 conditionSatisfied := true;
123                 return conditionSatisfied;
124             end if;
125         elsif operator = '<' then
126             if (to_date(leftHandSide, dateFormat) < to_date(rightHandSide, dateFormat)) then
127                 conditionSatisfied := true;
128                 return conditionSatisfied;
129             end if;
130         elsif operator = '>' then
131             if (to_date(leftHandSide, dateFormat) > to_date(rightHandSide, dateFormat)) then
132                 conditionSatisfied := true;
133                 return conditionSatisfied;
134             end if;
135         elsif operator = '<=' then
136             if (to_date(leftHandSide, dateFormat) <= to_date(rightHandSide, dateFormat)) then
137                 conditionSatisfied := true;
138                 return conditionSatisfied;
139             end if;
140         elsif operator = '>=' then
141             if (to_date(leftHandSide, dateFormat) >= to_date(rightHandSide, dateFormat)) then
142                 conditionSatisfied := true;
143                 return conditionSatisfied;
144             end if;
145         end if;
146      elsif valueDataType = 'T' then
147         if operator = '=' then
148             if (to_date(leftHandSide, timeFormat) = to_date(rightHandSide, timeFormat)) then
149                 conditionSatisfied := true;
150                 return conditionSatisfied;
151             end if;
152         elsif operator = '<>' then
153             if (to_date(leftHandSide, timeFormat) <> to_date(rightHandSide, timeFormat)) then
154                 conditionSatisfied := true;
155                 return conditionSatisfied;
156             end if;
157         elsif operator = '<' then
158             if (to_date(leftHandSide, timeFormat) < to_date(rightHandSide, timeFormat)) then
159                 conditionSatisfied := true;
160                 return conditionSatisfied;
161             end if;
162         elsif operator = '>' then
163             if (to_date(leftHandSide,timeFormat) > to_date(rightHandSide, timeFormat)) then
164                 conditionSatisfied := true;
165                 return conditionSatisfied;
166             end if;
167         elsif operator = '<=' then
168             if (to_date(leftHandSide, timeFormat) <= to_date(rightHandSide, timeFormat)) then
169                 conditionSatisfied := true;
170                 return conditionSatisfied;
171             end if;
172         elsif operator = '>=' then
173             if (to_date(leftHandSide, timeFormat) >= to_date(rightHandSide, timeFormat)) then
174                 conditionSatisfied := true;
175                 return conditionSatisfied;
176             end if;
177         end if;
178     else
179         Raise INVALID_DATATYPE;
180     end if;
181 
182     return conditionSatisfied;
183 
184     EXCEPTION
185         When INVALID_DATATYPE then
186 			if( FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
187             	errorMessage := '[' || leftHandSide || operator || rightHandSide || valueDataType || ']' || ' Invalid Datatype';
188             	FND_LOG.STRING(FND_LOG.LEVEL_EXCEPTION, 'IEM.PLSQL.IEM_OPERATORS_PVT.SATISFIED.INVALID_DATATYPE', errorMessage);
189            	end if;
190 
191 			conditionSatisfied := false;
192             return conditionSatisfied;
193         When VALUE_ERROR then
194 			if( FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
195             	errorMessage := '[' || leftHandSide || operator || rightHandSide || valueDataType || ']' || ' Invalid Number Format';
196             	FND_LOG.STRING(FND_LOG.LEVEL_EXCEPTION, 'IEM.PLSQL.IEM_OPERATORS_PVT.SATISFIED.VALUE_ERROR', errorMessage);
197             end if;
198 
199 			conditionSatisfied := false;
200             return conditionSatisfied;
201       When others then
202 	  	   if( FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
203                errorMessage := '[' || leftHandSide || operator || rightHandSide || valueDataType || '] ' || sqlerrm;
204                FND_LOG.STRING(FND_LOG.LEVEL_EXCEPTION, 'IEM.PLSQL.IEM_OPERATORS_PVT.SATISFIED.WHEN_OTHERS', errorMessage);
205            end if;
206 
207 		    conditionSatisfied := false;
208             return conditionSatisfied;
209 
210 end satisfied;
211 
212 
213 END IEM_OPERATORS_PVT;