DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_CTL_SHD

Source


1 Package Body ota_ctl_shd as
2 /* $Header: otctlrhi.pkb 120.2 2005/12/01 16:42 cmora noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ota_ctl_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   --
21   If (p_constraint_name = 'OTA_CERTIFICATIONS_TL_PK') Then
22     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
23     fnd_message.set_token('PROCEDURE', l_proc);
24     fnd_message.set_token('STEP','5');
25     fnd_message.raise_error;
26   Else
27     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
28     fnd_message.set_token('PROCEDURE', l_proc);
29     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
30     fnd_message.raise_error;
31   End If;
32   --
33 End constraint_error;
34 --
35 -- ----------------------------------------------------------------------------
36 -- |-----------------------------< api_updating >-----------------------------|
37 -- ----------------------------------------------------------------------------
38 Function api_updating
39   (p_certification_id                     in     number
40   ,p_language                             in     varchar2
41   )      Return Boolean Is
42 --
43   --
44   -- Cursor selects the 'current' row from the HR Schema
45   --
46   Cursor C_Sel1 is
47     select
48        certification_id
49       ,language
50       ,name
51       ,description
52       ,objectives
53       ,purpose
54       ,keywords
55       ,end_date_comments
56       ,initial_period_comments
57       ,renewal_period_comments
58       ,source_lang
59     from  ota_certifications_tl
60     where certification_id = p_certification_id
61     and   language = p_language;
62 --
63   l_fct_ret     boolean;
64 --
65 Begin
66   --
67   If (p_certification_id is null or
68       p_language is null
69      ) Then
70     --
71     -- One of the primary key arguments is null therefore we must
72     -- set the returning function value to false
73     --
74     l_fct_ret := false;
75   Else
76     If (p_certification_id
77         = ota_ctl_shd.g_old_rec.certification_id and
78         p_language
79         = ota_ctl_shd.g_old_rec.language
80        ) Then
81       --
82       -- The g_old_rec is current therefore we must
83       -- set the returning function to true
84       --
85       l_fct_ret := true;
86     Else
87       --
88       -- Select the current row into g_old_rec
89       --
90       Open C_Sel1;
91       Fetch C_Sel1 Into ota_ctl_shd.g_old_rec;
92       If C_Sel1%notfound Then
93         Close C_Sel1;
94         --
95         -- The primary key is invalid therefore we must error
96         --
97         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
98         fnd_message.raise_error;
99       End If;
100       Close C_Sel1;
101       --
102       l_fct_ret := true;
103     End If;
104   End If;
105   Return (l_fct_ret);
106 --
107 End api_updating;
108 --
109 -- ----------------------------------------------------------------------------
110 -- |---------------------------------< lck >----------------------------------|
111 -- ----------------------------------------------------------------------------
112 Procedure lck
113   (p_certification_id                     in     number
114   ,p_language                             in     varchar2
115   ) is
116 --
117 -- Cursor selects the 'current' row from the HR Schema
118 --
119   Cursor C_Sel1 is
120     select
121        certification_id
122       ,language
123       ,name
124       ,description
125       ,objectives
126       ,purpose
127       ,keywords
128       ,end_date_comments
129       ,initial_period_comments
130       ,renewal_period_comments
131       ,source_lang
132     from        ota_certifications_tl
133     where       certification_id = p_certification_id
134     and   language = p_language
135     for update nowait;
136 --
137   l_proc        varchar2(72) := g_package||'lck';
138 --
139 Begin
140   hr_utility.set_location('Entering:'||l_proc, 5);
141   --
142   hr_api.mandatory_arg_error
143     (p_api_name           => l_proc
144     ,p_argument           => 'CERTIFICATION_ID'
145     ,p_argument_value     => p_certification_id
146     );
147   hr_utility.set_location(l_proc,6);
148   hr_api.mandatory_arg_error
149     (p_api_name           => l_proc
150     ,p_argument           => 'LANGUAGE'
151     ,p_argument_value     => p_language
152     );
153   --
154   Open  C_Sel1;
155   Fetch C_Sel1 Into ota_ctl_shd.g_old_rec;
156   If C_Sel1%notfound then
157     Close C_Sel1;
158     --
159     -- The primary key is invalid therefore we must error
160     --
161     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
162     fnd_message.raise_error;
163   End If;
164   Close C_Sel1;
165   --
166   --
167   hr_utility.set_location(' Leaving:'||l_proc, 10);
168   --
169   -- We need to trap the ORA LOCK exception
170   --
171 Exception
172   When HR_Api.Object_Locked then
173     --
174     -- The object is locked therefore we need to supply a meaningful
175     -- error message.
176     --
177     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
178     fnd_message.set_token('TABLE_NAME', 'ota_certifications_tl');
179     fnd_message.raise_error;
180 End lck;
181 --
182 -- ----------------------------------------------------------------------------
183 -- |----------------------------< add_language >------------------------------|
184 -- ----------------------------------------------------------------------------
185 --  Executed AOL's tltblgen(UNIX) program to generate the
186 --  ADD_LANGUAGE procedure.
187 -- ----------------------------------------------------------------------------
188 procedure ADD_LANGUAGE
189 is
190 begin
191   delete from OTA_CERTIFICATIONS_TL T
192   where not exists
193     (select NULL
194     from OTA_CERTIFICATIONS_B B
195     where B.CERTIFICATION_ID = T.CERTIFICATION_ID
196     );
197 
198   update OTA_CERTIFICATIONS_TL T set (
199       NAME,
200       DESCRIPTION,
201       OBJECTIVES,
202       PURPOSE,
203       KEYWORDS,
204       END_DATE_COMMENTS,
205       INITIAL_PERIOD_COMMENTS,
206       RENEWAL_PERIOD_COMMENTS
207     ) = (select
208       B.NAME,
209       B.DESCRIPTION,
210       B.OBJECTIVES,
211       B.PURPOSE,
212       B.KEYWORDS,
213       B.END_DATE_COMMENTS,
214       B.INITIAL_PERIOD_COMMENTS,
215       B.RENEWAL_PERIOD_COMMENTS
216     from OTA_CERTIFICATIONS_TL B
217     where B.CERTIFICATION_ID = T.CERTIFICATION_ID
218     and B.LANGUAGE = T.SOURCE_LANG)
219   where (
220       T.CERTIFICATION_ID,
221       T.LANGUAGE
222   ) in (select
223       SUBT.CERTIFICATION_ID,
224       SUBT.LANGUAGE
225     from OTA_CERTIFICATIONS_TL SUBB, OTA_CERTIFICATIONS_TL SUBT
226     where SUBB.CERTIFICATION_ID = SUBT.CERTIFICATION_ID
227     and SUBB.LANGUAGE = SUBT.SOURCE_LANG
228     and (SUBB.NAME <> SUBT.NAME
229       or SUBB.DESCRIPTION <> SUBT.DESCRIPTION
230       or (SUBB.DESCRIPTION is null and SUBT.DESCRIPTION is not null)
231       or (SUBB.DESCRIPTION is not null and SUBT.DESCRIPTION is null)
232       or SUBB.OBJECTIVES <> SUBT.OBJECTIVES
233       or (SUBB.OBJECTIVES is null and SUBT.OBJECTIVES is not null)
234       or (SUBB.OBJECTIVES is not null and SUBT.OBJECTIVES is null)
235       or SUBB.PURPOSE <> SUBT.PURPOSE
236       or (SUBB.PURPOSE is null and SUBT.PURPOSE is not null)
237       or (SUBB.PURPOSE is not null and SUBT.PURPOSE is null)
238       or SUBB.KEYWORDS <> SUBT.KEYWORDS
239       or (SUBB.KEYWORDS is null and SUBT.KEYWORDS is not null)
240       or (SUBB.KEYWORDS is not null and SUBT.KEYWORDS is null)
241       or SUBB.END_DATE_COMMENTS <> SUBT.END_DATE_COMMENTS
242       or (SUBB.END_DATE_COMMENTS is null and SUBT.END_DATE_COMMENTS is not null)
243       or (SUBB.END_DATE_COMMENTS is not null and SUBT.END_DATE_COMMENTS is null)
244       or SUBB.INITIAL_PERIOD_COMMENTS <> SUBT.INITIAL_PERIOD_COMMENTS
245       or (SUBB.INITIAL_PERIOD_COMMENTS is null and SUBT.INITIAL_PERIOD_COMMENTS is not null)
246       or (SUBB.INITIAL_PERIOD_COMMENTS is not null and SUBT.INITIAL_PERIOD_COMMENTS is null)
247       or SUBB.RENEWAL_PERIOD_COMMENTS <> SUBT.RENEWAL_PERIOD_COMMENTS
248       or (SUBB.RENEWAL_PERIOD_COMMENTS is null and SUBT.RENEWAL_PERIOD_COMMENTS is not null)
249       or (SUBB.RENEWAL_PERIOD_COMMENTS is not null and SUBT.RENEWAL_PERIOD_COMMENTS is null)
250   ));
251 
252   insert into OTA_CERTIFICATIONS_TL (
253     LAST_UPDATE_DATE,
254     OBJECTIVES,
255     PURPOSE,
256     KEYWORDS,
257     END_DATE_COMMENTS,
258     INITIAL_PERIOD_COMMENTS,
259     RENEWAL_PERIOD_COMMENTS,
260     CREATED_BY,
261     CREATION_DATE,
262     NAME,
263     DESCRIPTION,
264     LAST_UPDATE_LOGIN,
265     CERTIFICATION_ID,
266     LAST_UPDATED_BY,
267     LANGUAGE,
268     SOURCE_LANG
269   ) select /*+ ORDERED */
270     B.LAST_UPDATE_DATE,
271     B.OBJECTIVES,
272     B.PURPOSE,
273     B.KEYWORDS,
274     B.END_DATE_COMMENTS,
275     B.INITIAL_PERIOD_COMMENTS,
276     B.RENEWAL_PERIOD_COMMENTS,
277     B.CREATED_BY,
278     B.CREATION_DATE,
279     B.NAME,
280     B.DESCRIPTION,
281     B.LAST_UPDATE_LOGIN,
282     B.CERTIFICATION_ID,
283     B.LAST_UPDATED_BY,
284     L.LANGUAGE_CODE,
285     B.SOURCE_LANG
286   from OTA_CERTIFICATIONS_TL B, FND_LANGUAGES L
287   where L.INSTALLED_FLAG in ('I', 'B')
288   and B.LANGUAGE = userenv('LANG')
289   and not exists
290     (select NULL
291     from OTA_CERTIFICATIONS_TL T
292     where T.CERTIFICATION_ID = B.CERTIFICATION_ID
293     and T.LANGUAGE = L.LANGUAGE_CODE);
294 end ADD_LANGUAGE;
295 --
296 -- ----------------------------------------------------------------------------
297 -- |-----------------------------< convert_args >-----------------------------|
298 -- ----------------------------------------------------------------------------
299 Function convert_args
300   (p_certification_id               in number
301   ,p_language                       in varchar2
302   ,p_name                           in varchar2
303   ,p_description                    in varchar2
304   ,p_objectives                     in varchar2
305   ,p_purpose                        in varchar2
306   ,p_keywords                       in varchar2
307   ,p_end_date_comments              in varchar2
308   ,p_initial_period_comments        in varchar2
309   ,p_renewal_period_comments        in varchar2
310   ,p_source_lang                    in varchar2
311   )
312   Return g_rec_type is
313 --
314   l_rec   g_rec_type;
315 --
316 Begin
317   --
318   -- Convert arguments into local l_rec structure.
319   --
320   l_rec.certification_id                 := p_certification_id;
321   l_rec.language                         := p_language;
322   l_rec.name                             := p_name;
323   l_rec.description                      := p_description;
324   l_rec.objectives                       := p_objectives;
325   l_rec.purpose                          := p_purpose;
326   l_rec.keywords                         := p_keywords;
327   l_rec.end_date_comments                := p_end_date_comments;
328   l_rec.initial_period_comments          := p_initial_period_comments;
329   l_rec.renewal_period_comments          := p_renewal_period_comments;
330   l_rec.source_lang                      := p_source_lang;
331   --
332   -- Return the plsql record structure.
333   --
334   Return(l_rec);
335 --
336 End convert_args;
337 --
338 end ota_ctl_shd;