DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_RTX_SHD

Source


1 Package Body per_rtx_shd as
2 /* $Header: pertxrhi.pkb 115.3 2004/06/28 23:22:17 kjagadee noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_rtx_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14   (p_constraint_name in all_constraints.constraint_name%TYPE
15   ) Is
16 --
17   l_proc        varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20  hr_utility.set_location('Entering:'||l_proc, 5);
21   --
22   If (p_constraint_name = 'PER_RATING_LEVELS_FK1') Then
23     hr_utility.set_message(801, 'HR_51471_RTL_RSC_NOT_EXIST');
24     hr_utility.set_message_token('PROCEDURE', l_proc);
25     hr_utility.set_message_token('STEP','5');
26     hr_utility.raise_error;
27   ElsIf (p_constraint_name = 'PER_RATING_LEVELS_FK2') Then
28     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
29     hr_utility.set_message_token('PROCEDURE', l_proc);
30     hr_utility.set_message_token('STEP','10');
31     hr_utility.raise_error;
32   ElsIf (p_constraint_name = 'PER_RATING_LEVELS_FK3') Then
33     hr_utility.set_message(801, 'HR_51472_RTL_CPN_NOT_EXIST');
34     hr_utility.set_message_token('PROCEDURE', l_proc);
35     hr_utility.set_message_token('STEP','15');
36     hr_utility.raise_error;
37   ElsIf (p_constraint_name = 'PER_RATING_LEVELS_PK') Then
38     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
39     hr_utility.set_message_token('PROCEDURE', l_proc);
40     hr_utility.set_message_token('STEP','20');
41     hr_utility.raise_error;
42   ElsIf (p_constraint_name = 'PER_RATING_LEVELS_UK2') Then
43     hr_utility.set_message(801, 'HR_51477_RTL_STEP_NOT_UNIQUE');
44     hr_utility.set_message_token('PROCEDURE', l_proc);
45     hr_utility.set_message_token('STEP','25');
46     hr_utility.raise_error;
47   ElsIf (p_constraint_name = 'PER_RATING_LEVELS_UK3') Then
48     hr_utility.set_message(801, 'HR_51474_RTL_NOT_UNIQUE');
49     hr_utility.set_message_token('PROCEDURE', l_proc);
50     hr_utility.set_message_token('STEP','30');
51     hr_utility.raise_error;
52   ElsIf (p_constraint_name = 'PER_RTL_CPN_OR_RSC_CHK') Then
53     hr_utility.set_message(801, 'HR_51482_RTL_RSC_OR_CPN');
54     hr_utility.set_message_token('PROCEDURE', l_proc);
55     hr_utility.set_message_token('STEP','35');
56     hr_utility.raise_error;
57   Else
58     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
59     hr_utility.set_message_token('PROCEDURE', l_proc);
60     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
61     hr_utility.raise_error;
62   End If;
63   --
64   hr_utility.set_location(' Leaving:'||l_proc, 10);
65 End constraint_error;
66 --
67 -- ----------------------------------------------------------------------------
68 -- |-----------------------------< api_updating >-----------------------------|
69 -- ----------------------------------------------------------------------------
70 Function api_updating
71   (p_rating_level_id                      in     number
72   ,p_language                             in     varchar2
73   )      Return Boolean Is
74 --
75   --
76   -- Cursor selects the 'current' row from the HR Schema
77   --
78   Cursor C_Sel1 is
79     select
80        rating_level_id
81       ,language
82       ,source_lang
83       ,name
84       ,behavioural_indicator
85     from  per_rating_levels_tl
86     where rating_level_id = p_rating_level_id
87     and   language = p_language;
88 --
89   l_fct_ret     boolean;
90 --
91 Begin
92   --
93   If (p_rating_level_id is null or
94       p_language is null
95      ) Then
96     --
97     -- One of the primary key arguments is null therefore we must
98     -- set the returning function value to false
99     --
100     l_fct_ret := false;
101   Else
102     If (p_rating_level_id
103         = per_rtx_shd.g_old_rec.rating_level_id and
104         p_language
105         = per_rtx_shd.g_old_rec.language
106        ) Then
107       --
108       -- The g_old_rec is current therefore we must
109       -- set the returning function to true
110       --
111       l_fct_ret := true;
112     Else
113       --
114       -- Select the current row into g_old_rec
115       --
116       Open C_Sel1;
117       Fetch C_Sel1 Into per_rtx_shd.g_old_rec;
118       If C_Sel1%notfound Then
119         Close C_Sel1;
120         --
121         -- The primary key is invalid therefore we must error
122         --
123         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
124         fnd_message.raise_error;
125       End If;
126       Close C_Sel1;
127       --
128       l_fct_ret := true;
129     End If;
130   End If;
131   Return (l_fct_ret);
132 --
133 End api_updating;
134 --
135 -- ----------------------------------------------------------------------------
136 -- |---------------------------------< lck >----------------------------------|
137 -- ----------------------------------------------------------------------------
138 Procedure lck
139   (p_rating_level_id                      in     number
140   ,p_language                             in     varchar2
141   ) is
142 --
143 -- Cursor selects the 'current' row from the HR Schema
144 --
145   Cursor C_Sel1 is
146     select
147        rating_level_id
148       ,language
149       ,source_lang
150       ,name
151       ,behavioural_indicator
152     from        per_rating_levels_tl
153     where       rating_level_id = p_rating_level_id
154     and   language = p_language
155     for update nowait;
156 --
157   l_proc        varchar2(72) := g_package||'lck';
158 --
159 Begin
160   hr_utility.set_location('Entering:'||l_proc, 5);
161   --
162   hr_api.mandatory_arg_error
163     (p_api_name           => l_proc
164     ,p_argument           => 'RATING_LEVEL_ID'
165     ,p_argument_value     => p_rating_level_id
166     );
167   hr_utility.set_location(l_proc,6);
168   hr_api.mandatory_arg_error
169     (p_api_name           => l_proc
170     ,p_argument           => 'LANGUAGE'
171     ,p_argument_value     => p_language
172     );
173   --
174   Open  C_Sel1;
175   Fetch C_Sel1 Into per_rtx_shd.g_old_rec;
176   If C_Sel1%notfound then
177     Close C_Sel1;
178     --
179     -- The primary key is invalid therefore we must error
180     --
181     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
182     fnd_message.raise_error;
183   End If;
184   Close C_Sel1;
185   --
186   --
187   hr_utility.set_location(' Leaving:'||l_proc, 10);
188   --
189   -- We need to trap the ORA LOCK exception
190   --
191 Exception
192   When HR_Api.Object_Locked then
193     --
194     -- The object is locked therefore we need to supply a meaningful
195     -- error message.
196     --
197     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
198     fnd_message.set_token('TABLE_NAME', 'per_rating_levels_tl');
199     fnd_message.raise_error;
200 End lck;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |----------------------------< add_language >------------------------------|
204 -- ----------------------------------------------------------------------------
205 -- MB added on 16-Dec-2002
206 procedure ADD_LANGUAGE
207 is
208 begin
209   delete from PER_RATING_LEVELS_TL T
210   where not exists
211     (select NULL
212     from PER_RATING_LEVELS B
213     where B.RATING_LEVEL_ID = T.RATING_LEVEL_ID
214     );
215 
216   update PER_RATING_LEVELS_TL T set (
217       NAME,
218       BEHAVIOURAL_INDICATOR
219     ) = (select
220       B.NAME,
221       B.BEHAVIOURAL_INDICATOR
222     from PER_RATING_LEVELS_TL B
223     where B.RATING_LEVEL_ID = T.RATING_LEVEL_ID
224     and B.LANGUAGE = T.SOURCE_LANG)
225   where (
226       T.RATING_LEVEL_ID,
227       T.LANGUAGE
228   ) in (select
229       SUBT.RATING_LEVEL_ID,
230       SUBT.LANGUAGE
231     from PER_RATING_LEVELS_TL SUBB, PER_RATING_LEVELS_TL SUBT
232     where SUBB.RATING_LEVEL_ID = SUBT.RATING_LEVEL_ID
233     and SUBB.LANGUAGE = SUBT.SOURCE_LANG
234     and (SUBB.NAME <> SUBT.NAME
235       or (SUBB.NAME is null and SUBT.NAME is not null)
236       or (SUBB.NAME is not null and SUBT.NAME is null)
237       or SUBB.BEHAVIOURAL_INDICATOR <> SUBT.BEHAVIOURAL_INDICATOR
238       or (SUBB.BEHAVIOURAL_INDICATOR is null and SUBT.BEHAVIOURAL_INDICATOR is not null)
239       or (SUBB.BEHAVIOURAL_INDICATOR is not null and SUBT.BEHAVIOURAL_INDICATOR is null)
240   ));
241 
242   insert into PER_RATING_LEVELS_TL (
243     RATING_LEVEL_ID,
244     NAME,
245     BEHAVIOURAL_INDICATOR,
246     CREATED_BY,
247     CREATION_DATE,
248     LAST_UPDATED_BY,
249     LAST_UPDATE_DATE,
250     LAST_UPDATE_LOGIN,
251     LANGUAGE,
252     SOURCE_LANG
253   ) select /*+ INDEX(b)*/
254     B.RATING_LEVEL_ID,
255     B.NAME,
256     B.BEHAVIOURAL_INDICATOR,
257     B.CREATED_BY,
258     B.CREATION_DATE,
259     B.LAST_UPDATED_BY,
260     B.LAST_UPDATE_DATE,
261     B.LAST_UPDATE_LOGIN,
262     L.LANGUAGE_CODE,
263     B.SOURCE_LANG
264   from PER_RATING_LEVELS_TL B, FND_LANGUAGES L
265   where L.INSTALLED_FLAG in ('I', 'B')
266   and B.LANGUAGE = userenv('LANG')
267   and not exists
268     (select NULL
269     from PER_RATING_LEVELS_TL T
270     where T.RATING_LEVEL_ID = B.RATING_LEVEL_ID
271     and T.LANGUAGE = L.LANGUAGE_CODE);
272 end ADD_LANGUAGE;
273 --
274 -- ----------------------------------------------------------------------------
275 -- |-----------------------------< convert_args >-----------------------------|
276 -- ----------------------------------------------------------------------------
277 Function convert_args
278   (p_rating_level_id                in number
279   ,p_language                       in varchar2
280   ,p_source_lang                    in varchar2
281   ,p_name                           in varchar2
282   ,p_behavioural_indicator          in varchar2
283   )
284   Return g_rec_type is
285 --
286   l_rec   g_rec_type;
287 --
288 Begin
289   --
290   -- Convert arguments into local l_rec structure.
291   --
292   l_rec.rating_level_id                  := p_rating_level_id;
293   l_rec.language                         := p_language;
294   l_rec.source_lang                      := p_source_lang;
295   l_rec.name                             := p_name;
296   l_rec.behavioural_indicator            := p_behavioural_indicator;
297   --
298   -- Return the plsql record structure.
299   --
300   Return(l_rec);
301 --
302 End convert_args;
303 --
304 end per_rtx_shd;