DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ESA_SHD

Source


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