[Home] [Help]
PACKAGE BODY: APPS.HR_HTL_SHD
Source
1 Package Body hr_htl_shd as
2 /* $Header: hrhtlrhi.pkb 115.1 2004/04/05 07:20:54 menderby noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_htl_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_HIERARCHIES_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_hierarchy_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 hierarchy_id
49 ,name
50 ,description
51 ,language
52 ,source_lang
53 from hr_ki_hierarchies_tl
54 where
55 hierarchy_id = p_hierarchy_id and language = p_language;
56 --
57 l_fct_ret boolean;
58 --
59 Begin
60 --
61 If (p_hierarchy_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_hierarchy_id
71 = hr_htl_shd.g_old_rec.hierarchy_id and
72 p_language
73 = hr_htl_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_htl_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_hierarchy_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 hierarchy_id
116 ,name
117 ,description
118 ,language
119 ,source_lang
120 from hr_ki_hierarchies_tl
121 where
122 hierarchy_id = p_hierarchy_id and language = p_language
123 for update nowait;
124 --
125 l_proc varchar2(72) := g_package||'lck';
126 --
127 Begin
128 hr_utility.set_location('Entering:'||l_proc, 5);
129 --
130 hr_api.mandatory_arg_error
131 (p_api_name => l_proc
132 ,p_argument => 'hierarchy_id'
133 ,p_argument_value => p_hierarchy_id
134 );
135 hr_utility.set_location(l_proc,6);
136 hr_api.mandatory_arg_error
137 (p_api_name => l_proc
138 ,p_argument => 'LANGUAGE'
139 ,p_argument_value => p_language
140 );
141 --
142 Open C_Sel1;
143 Fetch C_Sel1 Into hr_htl_shd.g_old_rec;
144 If C_Sel1%notfound then
145 Close C_Sel1;
146 --
147 -- The primary key is invalid therefore we must error
148 --
149 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
150 fnd_message.raise_error;
151 End If;
152 Close C_Sel1;
153 --
154 --
155 hr_utility.set_location(' Leaving:'||l_proc, 10);
156 --
157 -- We need to trap the ORA LOCK exception
158 --
159 Exception
160 When HR_Api.Object_Locked then
161 --
162 -- The object is locked therefore we need to supply a meaningful
163 -- error message.
164 --
165 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
166 fnd_message.set_token('TABLE_NAME', 'hr_ki_hierarchies_tl');
167 fnd_message.raise_error;
168 End lck;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |----------------------------< add_language >------------------------------|
172 -- ----------------------------------------------------------------------------
173 --
174 -- EDIT_HERE: Execute AOL's tltblgen(UNIX) program to generate the
175 -- ADD_LANGUAGE procedure. Only the add_language procedure
176 -- should be added here. Remove the following skeleton
177 -- procedure.
178 --
179 -- ----------------------------------------------------------------------------
180 PROCEDURE add_language IS
181 Begin
182 --
183 delete from HR_KI_HIERARCHIES_TL T
184 where not exists
185 (select NULL
186 from HR_KI_HIERARCHIES B
187 where B.HIERARCHY_ID = T.HIERARCHY_ID
188 );
189
190 update HR_KI_HIERARCHIES_TL T set (
191 NAME,
192 DESCRIPTION
193 ) = (select
194 B.NAME,
195 B.DESCRIPTION
196 from HR_KI_HIERARCHIES_TL B
197 where B.HIERARCHY_ID = T.HIERARCHY_ID
198 and B.LANGUAGE = T.SOURCE_LANG)
199 where (
200 T.HIERARCHY_ID,
201 T.LANGUAGE
202 ) in (select
203 SUBT.HIERARCHY_ID,
204 SUBT.LANGUAGE
205 from HR_KI_HIERARCHIES_TL SUBB, HR_KI_HIERARCHIES_TL SUBT
206 where SUBB.HIERARCHY_ID = SUBT.HIERARCHY_ID
207 and SUBB.LANGUAGE = SUBT.SOURCE_LANG
208 and (SUBB.NAME <> SUBT.NAME
209 or SUBB.DESCRIPTION <> SUBT.DESCRIPTION
210 or (SUBB.DESCRIPTION is null and SUBT.DESCRIPTION is not null)
211 or (SUBB.DESCRIPTION is not null and SUBT.DESCRIPTION is null)
212 ));
213
214 insert into HR_KI_HIERARCHIES_TL (
215 HIERARCHY_ID,
216 NAME,
217 LAST_UPDATED_BY,
218 LAST_UPDATE_LOGIN,
219 CREATED_BY,
220 CREATION_DATE,
221 LAST_UPDATE_DATE,
222 DESCRIPTION,
223 LANGUAGE,
224 SOURCE_LANG
225 ) select /*+ ORDERED */
226 B.HIERARCHY_ID,
227 B.NAME,
228 B.LAST_UPDATED_BY,
229 B.LAST_UPDATE_LOGIN,
230 B.CREATED_BY,
231 B.CREATION_DATE,
232 B.LAST_UPDATE_DATE,
233 B.DESCRIPTION,
234 L.LANGUAGE_CODE,
235 B.SOURCE_LANG
236 from HR_KI_HIERARCHIES_TL B, FND_LANGUAGES L
237 where L.INSTALLED_FLAG in ('I', 'B')
238 and B.LANGUAGE = userenv('LANG')
239 and not exists
240 (select NULL
241 from HR_KI_HIERARCHIES_TL T
242 where T.HIERARCHY_ID = B.HIERARCHY_ID
243 and T.LANGUAGE = L.LANGUAGE_CODE);
244
245 --
246 End;
247 --
248 -- ----------------------------------------------------------------------------
249 -- |-----------------------------< convert_args >-----------------------------|
250 -- ----------------------------------------------------------------------------
251 Function convert_args
252 (p_hierarchy_id in number
253 ,p_name in varchar2
254 ,p_description in varchar2
255 ,p_language in varchar2
256 ,p_source_lang in varchar2
257 )
258 Return g_rec_type is
259 --
260 l_rec g_rec_type;
261 --
262 Begin
263 --
264 -- Convert arguments into local l_rec structure.
265 --
266 l_rec.hierarchy_id := p_hierarchy_id;
267 l_rec.name := p_name;
268 l_rec.description := p_description;
269 l_rec.language := p_language;
270 l_rec.source_lang := p_source_lang;
271 --
272 -- Return the plsql record structure.
273 --
274 Return(l_rec);
275 --
276 End convert_args;
277 --
278 end hr_htl_shd;