DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_JOB_SHD

Source


1 Package Body per_job_shd as
2 /* $Header: pejobrhi.pkb 120.0.12010000.2 2009/05/12 06:16:11 varanjan ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_job_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_JOBS_FK1') Then
37     hr_utility.set_message(800, 'HR_52018_JOB_NO_BG');
38     hr_utility.set_message_token('PROCEDURE', l_proc);
39     hr_utility.set_message_token('STEP','5');
40     hr_utility.raise_error;
41   ElsIf (p_constraint_name = 'PER_JOBS_FK2') Then
42     hr_utility.set_message(800, 'HR_52017_JOB_DEF_INVALID');
43     hr_utility.set_message_token('PROCEDURE', l_proc);
44     hr_utility.set_message_token('STEP','10');
45     hr_utility.raise_error;
46   Elsif (p_constraint_name = 'PER_JOBS_FK3') Then
47     hr_utility.set_message(800,'HR_52670_JOB_GROUP_INV');
48     hr_utility.set_message_token('PROCEDURE',l_proc);
49     hr_utility.set_message_token('STEP','11');
50     hr_utility.raise_error;
51   ElsIf (p_constraint_name = 'PER_JOBS_PK') Then
52     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
53     hr_utility.set_message_token('PROCEDURE', l_proc);
54     hr_utility.set_message_token('STEP','15');
55     hr_utility.raise_error;
56 
57   ElsIf (p_constraint_name = 'PER_JOBS_UK2') Then
58     hr_utility.set_message(800, 'HR_52019_JOB_NAME_BG_EXISTS');
59     hr_utility.set_message_token('PROCEDURE', l_proc);
60     hr_utility.set_message_token('STEP','20');
61     hr_utility.raise_error;
62 
63   Else
64     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
65     hr_utility.set_message_token('PROCEDURE', l_proc);
66     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
67     hr_utility.raise_error;
68   End If;
69   --
70   hr_utility.set_location(' Leaving:'||l_proc, 10);
71 End constraint_error;
72 --
73 -- ----------------------------------------------------------------------------
74 -- |-----------------------------< api_updating >-----------------------------|
75 -- ----------------------------------------------------------------------------
76 Function api_updating
77   (
78    p_job_id                             in number,
79    p_object_version_number              in number
80   )
81    Return Boolean Is
82 --
83   --
84   -- Cursor selects the 'current' row from the HR Schema
85   --
86   Cursor C_Sel1 is
87     select
88       job_id,
89       business_group_id,
90       job_definition_id,
91       date_from,
92       comments,
93       date_to,
94       approval_authority,
95       name,
96       request_id,
97       program_application_id,
98       program_id,
99       program_update_date,
100       attribute_category,
101       attribute1,
102       attribute2,
103       attribute3,
104       attribute4,
105       attribute5,
106       attribute6,
107       attribute7,
108       attribute8,
109       attribute9,
110       attribute10,
111       attribute11,
112       attribute12,
113       attribute13,
114       attribute14,
115       attribute15,
116       attribute16,
117       attribute17,
118       attribute18,
119       attribute19,
120       attribute20,
121       job_information_category,
122       job_information1,
123       job_information2,
124       job_information3,
125       job_information4,
126       job_information5,
127       job_information6,
128       job_information7,
129       job_information8,
130       job_information9,
131       job_information10,
132       job_information11,
133       job_information12,
134       job_information13,
135       job_information14,
136       job_information15,
137       job_information16,
138       job_information17,
139       job_information18,
140       job_information19,
141       job_information20,
142     benchmark_job_flag,
143     benchmark_job_id,
144     emp_rights_flag,
145     job_group_id,
146       object_version_number
147     from     per_jobs
148     where    job_id = p_job_id;
149 --
150   l_proc varchar2(72)   := g_package||'api_updating';
151   l_fct_ret boolean;
152 --
153 Begin
157       p_job_id is null and
154   hr_utility.set_location('Entering:'||l_proc, 5);
155   --
156   If (
158       p_object_version_number is null
159      ) Then
160     --
161     -- One of the primary key arguments is null therefore we must
162     -- set the returning function value to false
163     --
164     l_fct_ret := false;
165   Else
166     If (
167         p_job_id                = g_old_rec.job_id and
168         p_object_version_number = g_old_rec.object_version_number
169        ) Then
170       hr_utility.set_location(l_proc, 10);
171       --
172       -- The g_old_rec is current therefore we must
173       -- set the returning function to true
174       --
175       l_fct_ret := true;
176     Else
177       --
178       -- Select the current row into g_old_rec
179       --
180       Open C_Sel1;
181       Fetch C_Sel1 Into g_old_rec;
182       If C_Sel1%notfound Then
183         Close C_Sel1;
184         --
185         -- The primary key is invalid therefore we must error
186         --
187         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
188         hr_utility.raise_error;
189       End If;
190       Close C_Sel1;
191       If (p_object_version_number <> g_old_rec.object_version_number) Then
192         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
193         hr_utility.raise_error;
194       End If;
195       hr_utility.set_location(l_proc, 15);
196       l_fct_ret := true;
197     End If;
198   End If;
199   hr_utility.set_location(' Leaving:'||l_proc, 20);
200   Return (l_fct_ret);
201 --
202 End api_updating;
203 --
204 -- ----------------------------------------------------------------------------
205 -- |---------------------------------< lck >----------------------------------|
206 -- ----------------------------------------------------------------------------
207 Procedure lck
208   (
209    p_job_id                             in number,
210    p_object_version_number              in number
211   ) is
212 --
213 -- Cursor selects the 'current' row from the HR Schema
214 --
215   Cursor C_Sel1 is
216     select
217       job_id,
218       business_group_id,
219       job_definition_id,
220       date_from,
221       comments,
222       date_to,
223       approval_authority,
224       name,
225       request_id,
226       program_application_id,
227       program_id,
228       program_update_date,
229       attribute_category,
230       attribute1,
231       attribute2,
232       attribute3,
233       attribute4,
234       attribute5,
235       attribute6,
236       attribute7,
237       attribute8,
238       attribute9,
239       attribute10,
240       attribute11,
241       attribute12,
242       attribute13,
243       attribute14,
244       attribute15,
245       attribute16,
246       attribute17,
247       attribute18,
248       attribute19,
249       attribute20,
250       job_information_category,
251       job_information1,
252       job_information2,
253       job_information3,
254       job_information4,
255       job_information5,
256       job_information6,
257       job_information7,
258       job_information8,
259       job_information9,
260       job_information10,
261       job_information11,
262       job_information12,
263       job_information13,
264       job_information14,
265       job_information15,
266       job_information16,
267       job_information17,
268       job_information18,
269       job_information19,
270       job_information20,
271     benchmark_job_flag,
272     benchmark_job_id,
273     emp_rights_flag,
274     job_group_id,
275       object_version_number
276     from     per_jobs
277     where    job_id = p_job_id
278     for  update nowait;
279 --
280   l_proc varchar2(72) := g_package||'lck';
281 --
282 Begin
283   hr_utility.set_location('Entering:'||l_proc, 5);
284   --
285   -- Add any mandatory argument checking here:
286   --
287   hr_api.mandatory_arg_error
288     (p_api_name       => l_proc
289     ,p_argument       => 'object_version_number'
290     ,p_argument_value => p_object_version_number);
291 --
292   Open  C_Sel1;
293   Fetch C_Sel1 Into g_old_rec;
294   If C_Sel1%notfound then
295     Close C_Sel1;
296     --
297     -- The primary key is invalid therefore we must error
298     --
299     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
300     hr_utility.raise_error;
301   End If;
302   Close C_Sel1;
303   If (p_object_version_number <> g_old_rec.object_version_number) Then
304         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
305         hr_utility.raise_error;
306       End If;
307 --
308   hr_utility.set_location(' Leaving:'||l_proc, 10);
309 --
310 -- We need to trap the ORA LOCK exception
311 --
312 Exception
313   When HR_Api.Object_Locked then
314     --
315     -- The object is locked therefore we need to supply a meaningful
316     -- error message.
317     --
318     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
319     hr_utility.set_message_token('TABLE_NAME', 'per_jobs');
320     hr_utility.raise_error;
321 End lck;
322 --
323 -- ----------------------------------------------------------------------------
327   (
324 -- |-----------------------------< convert_args >-----------------------------|
325 -- ----------------------------------------------------------------------------
326 Function convert_args
328    p_job_id                        in number,
329    p_business_group_id             in number,
330    p_job_definition_id             in number,
331    p_date_from                     in date,
332    p_comments                      in varchar2,
333    p_date_to                       in date,
334    p_approval_authority            in number,
335    p_name                          in varchar2,
336    p_request_id                    in number,
337    p_program_application_id        in number,
338    p_program_id                    in number,
339    p_program_update_date           in date,
340    p_attribute_category            in varchar2,
341    p_attribute1                    in varchar2,
342    p_attribute2                    in varchar2,
343    p_attribute3                    in varchar2,
344    p_attribute4                    in varchar2,
345    p_attribute5                    in varchar2,
346    p_attribute6                    in varchar2,
347    p_attribute7                    in varchar2,
348    p_attribute8                    in varchar2,
349    p_attribute9                    in varchar2,
350    p_attribute10                   in varchar2,
351    p_attribute11                   in varchar2,
352    p_attribute12                   in varchar2,
353    p_attribute13                   in varchar2,
354    p_attribute14                   in varchar2,
355    p_attribute15                   in varchar2,
356    p_attribute16                   in varchar2,
357    p_attribute17                   in varchar2,
358    p_attribute18                   in varchar2,
359    p_attribute19                   in varchar2,
360    p_attribute20                   in varchar2,
361    p_job_information_category      in varchar2,
362    p_job_information1              in varchar2,
363    p_job_information2              in varchar2,
364    p_job_information3              in varchar2,
365    p_job_information4              in varchar2,
366    p_job_information5              in varchar2,
367    p_job_information6              in varchar2,
368    p_job_information7              in varchar2,
369    p_job_information8              in varchar2,
370    p_job_information9              in varchar2,
371    p_job_information10             in varchar2,
372    p_job_information11             in varchar2,
373    p_job_information12             in varchar2,
374    p_job_information13             in varchar2,
375    p_job_information14             in varchar2,
376    p_job_information15             in varchar2,
377    p_job_information16             in varchar2,
378    p_job_information17             in varchar2,
379    p_job_information18             in varchar2,
380    p_job_information19             in varchar2,
381    p_job_information20             in varchar2,
382    p_benchmark_job_flag            in varchar2,
383    p_benchmark_job_id              in number,
384    p_emp_rights_flag               in varchar2,
385    p_job_group_id                  in number,
386    p_object_version_number         in number
387   )
388   Return g_rec_type is
389 --
390   l_rec    g_rec_type;
391   l_proc  varchar2(72) := g_package||'convert_args';
392 --
393 Begin
394   --
395   hr_utility.set_location('Entering:'||l_proc, 5);
396   --
397   -- Convert arguments into local l_rec structure.
398   --
399   l_rec.job_id                           := p_job_id;
400   hr_utility.set_location('Entering:'||l_proc, 1);
401   l_rec.business_group_id                := p_business_group_id;
402   hr_utility.set_location('Entering:'||l_proc, 2);
403   l_rec.job_definition_id                := p_job_definition_id;
404   hr_utility.set_location('Entering:'||l_proc, 3);
405   l_rec.date_from                        := p_date_from;
406   hr_utility.set_location('Entering:'||l_proc, 4);
407   l_rec.comments                         := p_comments;
408   hr_utility.set_location('Entering:'||l_proc, 5);
409   l_rec.date_to                          := p_date_to;
410   hr_utility.set_location('Entering:'||l_proc, 6);
411   l_rec.approval_authority               := p_approval_authority;
412   hr_utility.set_location('Entering:'||l_proc, 7);
413   l_rec.name                             := p_name;
414   hr_utility.set_location('Entering:'||l_proc, 8);
415   l_rec.request_id                       := p_request_id;
416   hr_utility.set_location('Entering:'||l_proc, 9);
417   l_rec.program_application_id           := p_program_application_id;
418   hr_utility.set_location('Entering:'||l_proc, 10);
419   l_rec.program_id                       := p_program_id;
420   hr_utility.set_location('Entering:'||l_proc, 11);
421   l_rec.program_update_date              := p_program_update_date;
422   hr_utility.set_location('Entering:'||l_proc, 12);
423   l_rec.attribute_category               := p_attribute_category;
424   hr_utility.set_location('Entering:'||l_proc, 13);
425   l_rec.attribute1                       := p_attribute1;
426   hr_utility.set_location('Entering:'||l_proc, 14);
427   l_rec.attribute2                       := p_attribute2;
428   hr_utility.set_location('Entering:'||l_proc, 15);
429   l_rec.attribute3                       := p_attribute3;
430   hr_utility.set_location('Entering:'||l_proc, 16);
431   l_rec.attribute4                       := p_attribute4;
432   hr_utility.set_location('Entering:'||l_proc, 17);
433   l_rec.attribute5                       := p_attribute5;
434   hr_utility.set_location('Entering:'||l_proc, 18);
435   l_rec.attribute6                       := p_attribute6;
436   hr_utility.set_location('Entering:'||l_proc, 19);
437   l_rec.attribute7                       := p_attribute7;
438   hr_utility.set_location('Entering:'||l_proc, 20);
439   l_rec.attribute8                       := p_attribute8;
440   hr_utility.set_location('Entering:'||l_proc, 21);
441   l_rec.attribute9                       := p_attribute9;
442   hr_utility.set_location('Entering:'||l_proc, 22);
443   l_rec.attribute10                      := p_attribute10;
444   hr_utility.set_location('Entering:'||l_proc, 23);
445   l_rec.attribute11                      := p_attribute11;
446   hr_utility.set_location('Entering:'||l_proc, 24);
447   l_rec.attribute12                      := p_attribute12;
448   hr_utility.set_location('Entering:'||l_proc, 25);
449   l_rec.attribute13                      := p_attribute13;
450   hr_utility.set_location('Entering:'||l_proc, 26);
451   l_rec.attribute14                      := p_attribute14;
452   hr_utility.set_location('Entering:'||l_proc, 27);
453   l_rec.attribute15                      := p_attribute15;
454   hr_utility.set_location('Entering:'||l_proc, 28);
455   l_rec.attribute16                      := p_attribute16;
456   hr_utility.set_location('Entering:'||l_proc, 29);
457   l_rec.attribute17                      := p_attribute17;
458   hr_utility.set_location('Entering:'||l_proc, 30);
459   l_rec.attribute18                      := p_attribute18;
460   hr_utility.set_location('Entering:'||l_proc, 31);
461   l_rec.attribute19                      := p_attribute19;
462   hr_utility.set_location('Entering:'||l_proc, 32);
463   l_rec.attribute20                      := p_attribute20;
464   hr_utility.set_location('Entering:'||l_proc, 33);
465   l_rec.job_information_category         := p_job_information_category;
466   hr_utility.set_location('Entering:'||l_proc, 34);
467   l_rec.job_information1                 := p_job_information1;
468   hr_utility.set_location('Entering:'||l_proc, 35);
469   l_rec.job_information2                 := p_job_information2;
470   hr_utility.set_location('Entering:'||l_proc, 36);
471   l_rec.job_information3                 := p_job_information3;
472   hr_utility.set_location('Entering:'||l_proc, 37);
473   l_rec.job_information4                 := p_job_information4;
474   hr_utility.set_location('Entering:'||l_proc, 38);
475   l_rec.job_information5                 := p_job_information5;
476   hr_utility.set_location('Entering:'||l_proc, 39);
477   l_rec.job_information6                 := p_job_information6;
478   hr_utility.set_location('Entering:'||l_proc, 40);
479   l_rec.job_information7                 := p_job_information7;
480   hr_utility.set_location('Entering:'||l_proc, 41);
481   l_rec.job_information8                 := p_job_information8;
482   hr_utility.set_location('Entering:'||l_proc, 42);
483   l_rec.job_information9                 := p_job_information9;
484   hr_utility.set_location('Entering:'||l_proc, 43);
485   l_rec.job_information10                := p_job_information10;
486   hr_utility.set_location('Entering:'||l_proc, 44);
487   l_rec.job_information11                := p_job_information11;
488   hr_utility.set_location('Entering:'||l_proc, 45);
489   l_rec.job_information12                := p_job_information12;
490   hr_utility.set_location('Entering:'||l_proc, 46);
491   l_rec.job_information13                := p_job_information13;
492   hr_utility.set_location('Entering:'||l_proc, 47);
493   l_rec.job_information14                := p_job_information14;
494   hr_utility.set_location('Entering:'||l_proc, 48);
495   l_rec.job_information15                := p_job_information15;
496   hr_utility.set_location('Entering:'||l_proc, 49);
497   l_rec.job_information16                := p_job_information16;
498   hr_utility.set_location('Entering:'||l_proc, 50);
499   l_rec.job_information17                := p_job_information17;
500   hr_utility.set_location('Entering:'||l_proc, 51);
501   l_rec.job_information18                := p_job_information18;
502   hr_utility.set_location('Entering:'||l_proc, 52);
503   l_rec.job_information19                := p_job_information19;
504   hr_utility.set_location('Entering:'||l_proc, 53);
505   l_rec.job_information20                := p_job_information20;
506   hr_utility.set_location('Entering:'||l_proc, 54);
507   l_rec.benchmark_job_flag               := p_benchmark_job_flag;
508   hr_utility.set_location('Entering:'||l_proc, 55);
509   l_rec.benchmark_job_id                 := p_benchmark_job_id;
510   hr_utility.set_location('Entering:'||l_proc, 56);
511   l_rec.emp_rights_flag                  := p_emp_rights_flag;
512   hr_utility.set_location('Entering:'||l_proc, 57);
513   l_rec.job_group_id                     := p_job_group_id;
514   hr_utility.set_location('Entering:'||l_proc, 58);
515   l_rec.object_version_number            := p_object_version_number;
516   hr_utility.set_location('Entering:'||l_proc, 59);
517   --
518   -- Return the plsql record structure.
519   --
520   hr_utility.set_location(' Leaving:'||l_proc, 10);
521   Return(l_rec);
522 --
523 End convert_args;
524 --
525 end per_job_shd;