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