DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_SUC_SHD

Source


1 Package Body per_suc_shd as
2 /* $Header: pesucrhi.pkb 120.1 2008/02/05 07:07:45 schowdhu noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_suc_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
15   l_proc 	varchar2(72) := g_package||'return_api_dml_status';
16 --
17 Begin
18   hr_utility.set_location('Entering:'||l_proc, 5);
19   --
20   Return (nvl(g_api_dml, false));
21   --
22   hr_utility.set_location(' Leaving:'||l_proc, 10);
23 End return_api_dml_status;
24 --
25 -- ----------------------------------------------------------------------------
26 -- |---------------------------< constraint_error >---------------------------|
27 -- ----------------------------------------------------------------------------
28 Procedure constraint_error
29             (p_constraint_name in all_constraints.constraint_name%TYPE) Is
30 --
31   l_proc 	varchar2(72) := g_package||'constraint_error';
32 --
33 Begin
34   hr_utility.set_location('Entering:'||l_proc, 5);
35   --
36   If (p_constraint_name = 'PER_SUCCESSION_PLANNING_FK1') Then
37     hr_utility.set_message(801,'HR_52000_SUC_CHK_POS_EXISTS');
38     hr_utility.raise_error;
39   ElsIf (p_constraint_name = 'PER_SUCCESSION_PLANNING_FK2') Then
40     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
41     hr_utility.set_message_token('PROCEDURE', l_proc);
42     hr_utility.set_message_token('STEP','10');
43     hr_utility.raise_error;
44   ElsIf (p_constraint_name = 'PER_SUCCESSION_PLANNING_PK') Then
45     hr_utility.set_message(801, 'HR_52006_SUC_CHK_SUCC_PLAN_ID');
46     hr_utility.raise_error;
47   ElsIf (p_constraint_name = 'PER_SUCCESSION_PLANNING_UK') Then
48     hr_utility.set_message(801,'HR_52005_SUC_CHK_DATE');
49     hr_utility.raise_error;
50   ElsIf (p_constraint_name = 'PER_SUC_AVAIL_FOR_PROMOTION') Then
51     hr_utility.set_message(801,'HR_52004_SUC_CHK_AVAILABLE');
52     hr_utility.raise_error;
53   Else
54     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
55     hr_utility.set_message_token('PROCEDURE', l_proc);
56     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
57     hr_utility.raise_error;
58   End If;
59   --
60   hr_utility.set_location(' Leaving:'||l_proc, 10);
61 End constraint_error;
62 --
63 -- ----------------------------------------------------------------------------
64 -- |-----------------------------< api_updating >-----------------------------|
65 -- ----------------------------------------------------------------------------
66 Function api_updating
67   (
68   p_succession_plan_id                 in number,
69   p_object_version_number              in number
70   )      Return Boolean Is
71 --
72   --
73   -- Cursor selects the 'current' row from the HR Schema
74   --
75   Cursor C_Sel1 is
76     select
77 	succession_plan_id,
78 	person_id,
79 	position_id,
80 	business_group_id,
81 	start_date,
82 	time_scale,
83 	end_date,
84 	available_for_promotion,
85 	manager_comments,
86 	object_version_number,
87 	attribute_category,
88 	attribute1,
89 	attribute2,
90 	attribute3,
91 	attribute4,
92 	attribute5,
93 	attribute6,
94 	attribute7,
95 	attribute8,
96 	attribute9,
97 	attribute10,
98 	attribute11,
99 	attribute12,
100 	attribute13,
101 	attribute14,
102 	attribute15,
103 	attribute16,
104 	attribute17,
105 	attribute18,
106 	attribute19,
107 	attribute20,
108 	job_id,
109 	successee_person_id
110     from	per_succession_planning
111     where	succession_plan_id = p_succession_plan_id;
112 --
113   l_proc	varchar2(72)	:= g_package||'api_updating';
114   l_fct_ret	boolean;
115 --
116 Begin
117   hr_utility.set_location('Entering:'||l_proc, 5);
118   --
119   If (
120 	p_succession_plan_id is null and
121 	p_object_version_number is null
122      ) Then
123     --
124     -- One of the primary key arguments is null therefore we must
125     -- set the returning function value to false
126     --
127     l_fct_ret := false;
128   Else
129     If (
130 	p_succession_plan_id = g_old_rec.succession_plan_id and
131 	p_object_version_number = g_old_rec.object_version_number
132        ) Then
133       hr_utility.set_location(l_proc, 10);
134       --
135       -- The g_old_rec is current therefore we must
136       -- set the returning function to true
137       --
138       l_fct_ret := true;
139     Else
140       --
141       -- Select the current row into g_old_rec
142       --
143       Open C_Sel1;
144       Fetch C_Sel1 Into g_old_rec;
145       If C_Sel1%notfound Then
146         Close C_Sel1;
147         --
148         -- The primary key is invalid therefore we must error
149         --
150         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
151         hr_utility.raise_error;
152       End If;
153       Close C_Sel1;
154       If (p_object_version_number <> g_old_rec.object_version_number) Then
155         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
156         hr_utility.raise_error;
157       End If;
158       hr_utility.set_location(l_proc, 15);
159       l_fct_ret := true;
160     End If;
161   End If;
162   hr_utility.set_location(' Leaving:'||l_proc, 20);
163   Return (l_fct_ret);
164 --
165 End api_updating;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |---------------------------------< lck >----------------------------------|
169 -- ----------------------------------------------------------------------------
170 Procedure lck
171   (
172   p_succession_plan_id                 in number,
173   p_object_version_number              in number
174   ) is
175 --
176 -- Cursor selects the 'current' row from the HR Schema
177 --
178   Cursor C_Sel1 is
179     select 	succession_plan_id,
180 	person_id,
181 	position_id,
182 	business_group_id,
183 	start_date,
184 	time_scale,
185 	end_date,
186 	available_for_promotion,
187 	manager_comments,
188 	object_version_number,
189 	attribute_category,
190 	attribute1,
191 	attribute2,
192 	attribute3,
193 	attribute4,
194 	attribute5,
195 	attribute6,
196 	attribute7,
197 	attribute8,
198 	attribute9,
199 	attribute10,
200 	attribute11,
201 	attribute12,
202 	attribute13,
203 	attribute14,
204 	attribute15,
205 	attribute16,
206 	attribute17,
207 	attribute18,
208 	attribute19,
209 	attribute20,
210 	job_id,
211 	successee_person_id
212     from	per_succession_planning
213     where	succession_plan_id = p_succession_plan_id
214     for	update nowait;
215 --
216   l_proc	varchar2(72) := g_package||'lck';
217 --
218 Begin
219   hr_utility.set_location('Entering:'||l_proc, 5);
220   --
221   -- Add any mandatory argument checking here:
222   -- Example:
223   -- hr_api.mandatory_arg_error
224   --   (p_api_name       => l_proc,
225   --    p_argument       => 'object_version_number',
226   --    p_argument_value => p_object_version_number);
227   --
228   Open  C_Sel1;
229   Fetch C_Sel1 Into g_old_rec;
230   If C_Sel1%notfound then
231     Close C_Sel1;
232     --
233     -- The primary key is invalid therefore we must error
234     --
235     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
236     hr_utility.raise_error;
237   End If;
238   Close C_Sel1;
239   If (p_object_version_number <> g_old_rec.object_version_number) Then
240         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
241         hr_utility.raise_error;
242       End If;
243 --
244   hr_utility.set_location(' Leaving:'||l_proc, 10);
245 --
246 -- We need to trap the ORA LOCK exception
247 --
248 Exception
249   When HR_Api.Object_Locked then
250     --
251     -- The object is locked therefore we need to supply a meaningful
252     -- error message.
253     --
254     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
255     hr_utility.set_message_token('TABLE_NAME', 'per_succession_planning');
256     hr_utility.raise_error;
257 End lck;
258 --
259 -- ----------------------------------------------------------------------------
260 -- |-----------------------------< convert_args >-----------------------------|
261 -- ----------------------------------------------------------------------------
262 Function convert_args
263 	(
264 	p_succession_plan_id            in number,
265 	p_person_id                     in number,
266 	p_position_id                   in number,
267 	p_business_group_id             in number,
268 	p_start_date                    in date,
269 	p_time_scale                    in varchar2,
270 	p_end_date                      in date,
271 	p_available_for_promotion       in varchar2,
272 	p_manager_comments              in varchar2,
273 	p_object_version_number         in number,
274 	p_attribute_category            in varchar2,
275 	p_attribute1                    in varchar2,
276 	p_attribute2                    in varchar2,
277 	p_attribute3                    in varchar2,
278 	p_attribute4                    in varchar2,
279 	p_attribute5                    in varchar2,
280 	p_attribute6                    in varchar2,
281 	p_attribute7                    in varchar2,
282 	p_attribute8                    in varchar2,
283 	p_attribute9                    in varchar2,
284 	p_attribute10                   in varchar2,
285 	p_attribute11                   in varchar2,
286 	p_attribute12                   in varchar2,
287 	p_attribute13                   in varchar2,
288 	p_attribute14                   in varchar2,
289 	p_attribute15                   in varchar2,
290 	p_attribute16                   in varchar2,
291 	p_attribute17                   in varchar2,
292 	p_attribute18                   in varchar2,
293 	p_attribute19                   in varchar2,
294 	p_attribute20                   in varchar2,
295 	p_job_id                        in number,
296 	p_successee_person_id           in number
297 	)
298 	Return g_rec_type is
299 --
300   l_rec	  g_rec_type;
301   l_proc  varchar2(72) := g_package||'convert_args';
302 --
303 Begin
304   --
305   hr_utility.set_location('Entering:'||l_proc, 5);
306   --
307   -- Convert arguments into local l_rec structure.
308   --
309   l_rec.succession_plan_id               := p_succession_plan_id;
310   l_rec.person_id                        := p_person_id;
311   l_rec.position_id                      := p_position_id;
312   l_rec.business_group_id                := p_business_group_id;
313   l_rec.start_date                       := p_start_date;
314   l_rec.time_scale                       := p_time_scale;
315   l_rec.end_date                         := p_end_date;
316   l_rec.available_for_promotion          := p_available_for_promotion;
317   l_rec.manager_comments                 := p_manager_comments;
318   l_rec.object_version_number            := p_object_version_number;
319   l_rec.attribute_category               := p_attribute_category;
320   l_rec.attribute1                       := p_attribute1;
321   l_rec.attribute2                       := p_attribute2;
322   l_rec.attribute3                       := p_attribute3;
323   l_rec.attribute4                       := p_attribute4;
324   l_rec.attribute5                       := p_attribute5;
325   l_rec.attribute6                       := p_attribute6;
326   l_rec.attribute7                       := p_attribute7;
327   l_rec.attribute8                       := p_attribute8;
328   l_rec.attribute9                       := p_attribute9;
329   l_rec.attribute10                      := p_attribute10;
330   l_rec.attribute11                      := p_attribute11;
331   l_rec.attribute12                      := p_attribute12;
332   l_rec.attribute13                      := p_attribute13;
333   l_rec.attribute14                      := p_attribute14;
334   l_rec.attribute15                      := p_attribute15;
335   l_rec.attribute16                      := p_attribute16;
336   l_rec.attribute17                      := p_attribute17;
337   l_rec.attribute18                      := p_attribute18;
338   l_rec.attribute19                      := p_attribute19;
339   l_rec.attribute20                      := p_attribute20;
340   l_rec.job_id                           := p_job_id;
341   l_rec.successee_person_id              := p_successee_person_id;
342   --
343   -- Return the plsql record structure.
344   --
345   hr_utility.set_location(' Leaving:'||l_proc, 10);
346   Return(l_rec);
347 --
348 End convert_args;
349 --
350 end per_suc_shd;