DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_OTT_SHD

Source


1 PACKAGE BODY HR_OTT_SHD as
2 /* $Header: hrottrhi.pkb 115.1 2004/04/05 07:21:14 menderby noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_ott_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 = 'HR_KI_OPTION_TYPES_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_option_type_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        option_type_id
49       ,option_name
50       ,language
51       ,source_lang
52     from  hr_ki_option_types_tl
53     where
54      option_type_id = p_option_type_id
55      and language = p_language;
56 --
57   l_fct_ret     boolean;
58 --
59 Begin
60   --
61   If (p_option_type_id is null or
62       p_language is null
63      ) Then
64     --
65     -- One of the primary key arguments is null therefore we must
66     -- set the returning function value to false
67     --
68     l_fct_ret := false;
69   Else
70     If (p_option_type_id
71         = hr_ott_shd.g_old_rec.option_type_id and
72         p_language
73         = hr_ott_shd.g_old_rec.language
74        ) Then
75       --
76       -- The g_old_rec is current therefore we must
77       -- set the returning function to true
78       --
79       l_fct_ret := true;
80     Else
81       --
82       -- Select the current row into g_old_rec
83       --
84       Open C_Sel1;
85       Fetch C_Sel1 Into hr_ott_shd.g_old_rec;
86       If C_Sel1%notfound Then
87         Close C_Sel1;
88         --
89         -- The primary key is invalid therefore we must error
90         --
91         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
92         fnd_message.raise_error;
93       End If;
94       Close C_Sel1;
95       --
96       l_fct_ret := true;
97     End If;
98   End If;
99   Return (l_fct_ret);
100 --
101 End api_updating;
102 --
103 -- ----------------------------------------------------------------------------
104 -- |---------------------------------< lck >----------------------------------|
105 -- ----------------------------------------------------------------------------
106 Procedure lck
107   (p_option_type_id                       in     number
108   ,p_language                             in     varchar2
109   ) is
110 --
111 -- Cursor selects the 'current' row from the HR Schema
112 --
113   Cursor C_Sel1 is
114     select
115        option_type_id
116       ,option_name
117       ,language
118       ,source_lang
119     from        hr_ki_option_types_tl
120     where
121     option_type_id = p_option_type_id and language = p_language
122     for update nowait;
123 --
124   l_proc        varchar2(72) := g_package||'lck';
125 --
126 Begin
127   hr_utility.set_location('Entering:'||l_proc, 5);
128   --
129   hr_api.mandatory_arg_error
130     (p_api_name           => l_proc
131     ,p_argument           => 'OPTION_TYPE_ID'
132     ,p_argument_value     => p_option_type_id
133     );
134   hr_utility.set_location(l_proc,6);
135   hr_api.mandatory_arg_error
136     (p_api_name           => l_proc
137     ,p_argument           => 'LANGUAGE'
138     ,p_argument_value     => p_language
139     );
140   --
141   Open  C_Sel1;
142   Fetch C_Sel1 Into hr_ott_shd.g_old_rec;
143   If C_Sel1%notfound then
144     Close C_Sel1;
145     --
146     -- The primary key is invalid therefore we must error
147     --
148     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
149     fnd_message.raise_error;
150   End If;
151   Close C_Sel1;
152   --
153   --
154   hr_utility.set_location(' Leaving:'||l_proc, 10);
155   --
156   -- We need to trap the ORA LOCK exception
157   --
158 Exception
159   When HR_Api.Object_Locked then
160     --
161     -- The object is locked therefore we need to supply a meaningful
162     -- error message.
163     --
164     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
165     fnd_message.set_token('TABLE_NAME', 'hr_ki_option_types_tl');
166     fnd_message.raise_error;
167 End lck;
168 --
169 -- ----------------------------------------------------------------------------
170 -- |----------------------------< add_language >------------------------------|
171 -- ----------------------------------------------------------------------------
172 -- ----------------------------------------------------------------------------
173 
174 procedure ADD_LANGUAGE
175 is
176 begin
177   delete from HR_KI_OPTION_TYPES_TL T
178   where not exists
179     (select NULL
180     from HR_KI_OPTION_TYPES B
181     where B.OPTION_TYPE_ID = T.OPTION_TYPE_ID
182     );
183 
184   update HR_KI_OPTION_TYPES_TL T set (
185       OPTION_NAME
186     ) = (select
187       B.OPTION_NAME
188     from HR_KI_OPTION_TYPES_TL B
189     where B.OPTION_TYPE_ID = T.OPTION_TYPE_ID
190     and B.LANGUAGE = T.SOURCE_LANG)
191   where (
192       T.OPTION_TYPE_ID,
193       T.LANGUAGE
194   ) in (select
195       SUBT.OPTION_TYPE_ID,
196       SUBT.LANGUAGE
197     from HR_KI_OPTION_TYPES_TL SUBB, HR_KI_OPTION_TYPES_TL SUBT
198     where SUBB.OPTION_TYPE_ID = SUBT.OPTION_TYPE_ID
199     and SUBB.LANGUAGE = SUBT.SOURCE_LANG
200     and (SUBB.OPTION_NAME <> SUBT.OPTION_NAME
201   ));
202 
203   insert into HR_KI_OPTION_TYPES_TL (
204     OPTION_TYPE_ID,
205     OPTION_NAME,
206     LAST_UPDATE_DATE,
207     LAST_UPDATED_BY,
208     LAST_UPDATE_LOGIN,
209     CREATED_BY,
210     CREATION_DATE,
211     LANGUAGE,
212     SOURCE_LANG
213   ) select /*+ ORDERED */
214     B.OPTION_TYPE_ID,
215     B.OPTION_NAME,
216     B.LAST_UPDATE_DATE,
217     B.LAST_UPDATED_BY,
218     B.LAST_UPDATE_LOGIN,
219     B.CREATED_BY,
220     B.CREATION_DATE,
221     L.LANGUAGE_CODE,
222     B.SOURCE_LANG
223   from HR_KI_OPTION_TYPES_TL B, FND_LANGUAGES L
224   where L.INSTALLED_FLAG in ('I', 'B')
225   and B.LANGUAGE = userenv('LANG')
226   and not exists
227     (select NULL
228     from HR_KI_OPTION_TYPES_TL T
229     where T.OPTION_TYPE_ID = B.OPTION_TYPE_ID
230     and T.LANGUAGE = L.LANGUAGE_CODE);
231 end ADD_LANGUAGE;
232 
233 
234 --
235 -- ----------------------------------------------------------------------------
236 -- |-----------------------------< convert_args >-----------------------------|
237 -- ----------------------------------------------------------------------------
238 Function convert_args
239   (p_option_type_id                 in number
240   ,p_option_name                    in varchar2
241   ,p_language                       in varchar2
242   ,p_source_lang                    in varchar2
243   )
244   Return g_rec_type is
245 --
246   l_rec   g_rec_type;
247 --
248 Begin
249   --
250   -- Convert arguments into local l_rec structure.
251   --
252   l_rec.option_type_id                   := p_option_type_id;
253   l_rec.option_name                      := p_option_name;
254   l_rec.language                         := p_language;
255   l_rec.source_lang                      := p_source_lang;
256   --
257   -- Return the plsql record structure.
258   --
259   Return(l_rec);
260 --
261 End convert_args;
262 --
263 end hr_ott_shd;