DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_KAD_SHD

Source


1 Package Body per_kad_shd as
2 /* $Header: pekadrhi.pkb 115.6 2002/12/06 11:27:37 pkakar ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_kad_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   -- 70.2 change d start.
37   --
38   If (p_constraint_name = 'PER_ADDRESSES_PK') Then
39     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
40     hr_utility.raise_error;
41   ElsIf (p_constraint_name = 'PER_ADDR_PRIMARY_FLAG_CHK') Then
42     hr_utility.set_message(801, 'HR_7325_ADD_INVALID_PRIM_FLAG');
43     hr_utility.raise_error;
44   Else
45     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
46     hr_utility.set_message_token('PROCEDURE', l_proc);
47     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
48     hr_utility.raise_error;
49   End If;
50   --
51   -- 70.2 change d end.
52   --
53   hr_utility.set_location(' Leaving:'||l_proc, 10);
54 End constraint_error;
55 --
56 -- ----------------------------------------------------------------------------
57 -- |-----------------------------< api_updating >-----------------------------|
58 -- ----------------------------------------------------------------------------
59 Function api_updating
60   (
61   p_address_id                         in number,
62   p_object_version_number              in number
63   )      Return Boolean Is
64 --
65   --
66   -- Cursor selects the 'current' row from the HR Schema
67   --
68   Cursor C_Sel1 is
69     select
70 	address_id,
71 	business_group_id,
72 	person_id,
73 	date_from,
74 	primary_flag,
75 	style,
76 	address_line1,
77 	address_line2,
78 	address_line3,
79 	address_type,
80 	comments,
81 	country,
82 	date_to,
83 	postal_code,
84 	region_1,
85 	region_2,
86 	region_3,
87 	telephone_number_1,
88 	telephone_number_2,
89 	telephone_number_3,
90 	town_or_city,
91 	request_id,
92 	program_application_id,
93 	program_id,
94 	program_update_date,
95 	addr_attribute_category,
96 	addr_attribute1,
97 	addr_attribute2,
98 	addr_attribute3,
99 	addr_attribute4,
100 	addr_attribute5,
101 	addr_attribute6,
102 	addr_attribute7,
103 	addr_attribute8,
104 	addr_attribute9,
105 	addr_attribute10,
106 	addr_attribute11,
107 	addr_attribute12,
108 	addr_attribute13,
109 	addr_attribute14,
110 	addr_attribute15,
111 	addr_attribute16,
112 	addr_attribute17,
113 	addr_attribute18,
114 	addr_attribute19,
115 	addr_attribute20,
116 	object_version_number
117     from	per_addresses
118     where	address_id = p_address_id;
119 --
120   l_proc	varchar2(72)	:= g_package||'api_updating';
121   l_fct_ret	boolean;
122 --
123 Begin
124   hr_utility.set_location('Entering:'||l_proc, 5);
125   --
126   If (
127 	p_address_id is null and
128 	p_object_version_number is null
129      ) Then
130     --
131     -- One of the primary key arguments is null therefore we must
132     -- set the returning function value to false
133     --
134     l_fct_ret := false;
135   Else
136     If (
137 	p_address_id = g_old_rec.address_id and
138 	p_object_version_number = g_old_rec.object_version_number
139        ) Then
140       hr_utility.set_location(l_proc, 10);
141       --
142       -- The g_old_rec is current therefore we must
143       -- set the returning function to true
144       --
145       l_fct_ret := true;
146     Else
147       --
148       -- Select the current row into g_old_rec
149       --
150       Open C_Sel1;
151       Fetch C_Sel1 Into g_old_rec;
152       If C_Sel1%notfound Then
153         Close C_Sel1;
154         --
155         -- The primary key is invalid therefore we must error
156         --
157         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
158         hr_utility.raise_error;
159       End If;
160       Close C_Sel1;
161       If (p_object_version_number <> g_old_rec.object_version_number) Then
162         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
163         hr_utility.raise_error;
164       End If;
165       hr_utility.set_location(l_proc, 15);
166       l_fct_ret := true;
167     End If;
168   End If;
169   hr_utility.set_location(' Leaving:'||l_proc, 20);
170   Return (l_fct_ret);
171 --
172 End api_updating;
173 --
174 -- ----------------------------------------------------------------------------
175 -- |---------------------------------< lck >----------------------------------|
176 -- ----------------------------------------------------------------------------
177 Procedure lck
178   (
179   p_address_id                         in number,
180   p_object_version_number              in number
181   ) is
182 --
183 -- Cursor selects the 'current' row from the HR Schema
184 --
185   Cursor C_Sel1 is
186     select 	address_id,
187 	business_group_id,
188 	person_id,
189 	date_from,
190 	primary_flag,
191 	style,
192 	address_line1,
193 	address_line2,
194 	address_line3,
195 	address_type,
196 	comments,
197 	country,
198 	date_to,
199 	postal_code,
200 	region_1,
201 	region_2,
202 	region_3,
203 	telephone_number_1,
204 	telephone_number_2,
205 	telephone_number_3,
206 	town_or_city,
207 	request_id,
208 	program_application_id,
209 	program_id,
210 	program_update_date,
211 	addr_attribute_category,
212 	addr_attribute1,
213 	addr_attribute2,
214 	addr_attribute3,
215 	addr_attribute4,
216 	addr_attribute5,
217 	addr_attribute6,
218 	addr_attribute7,
219 	addr_attribute8,
220 	addr_attribute9,
221 	addr_attribute10,
222 	addr_attribute11,
223 	addr_attribute12,
224 	addr_attribute13,
225 	addr_attribute14,
226 	addr_attribute15,
227 	addr_attribute16,
228 	addr_attribute17,
229 	addr_attribute18,
230 	addr_attribute19,
231 	addr_attribute20,
232 	object_version_number
233     from	per_addresses
234     where	address_id = p_address_id
235     for	update nowait;
236 --
237   l_proc	varchar2(72) := g_package||'lck';
238 --
239 Begin
240   hr_utility.set_location('Entering:'||l_proc, 5);
241   --
242   hr_api.mandatory_arg_error
243     (p_api_name       => l_proc
244     ,p_argument       => 'address_id'
245     , p_argument_value => p_address_id);
246   --
247   hr_api.mandatory_arg_error
248     (p_api_name       => l_proc,
249      p_argument       => 'object_version_number',
250      p_argument_value => p_object_version_number);
251   --
252   Open  C_Sel1;
253   Fetch C_Sel1 Into g_old_rec;
254   If C_Sel1%notfound then
255     Close C_Sel1;
256     --
257     -- The primary key is invalid therefore we must error
258     --
259     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
260     hr_utility.raise_error;
261   End If;
262   Close C_Sel1;
263   If (p_object_version_number <> g_old_rec.object_version_number) Then
264         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
265         hr_utility.raise_error;
266       End If;
267 --
268   hr_utility.set_location(' Leaving:'||l_proc, 10);
269 --
270 -- We need to trap the ORA LOCK exception
271 --
272 Exception
273   When HR_Api.Object_Locked then
274     --
275     -- The object is locked therefore we need to supply a meaningful
276     -- error message.
277     --
278     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
279     hr_utility.set_message_token('TABLE_NAME', 'per_addresses');
280     hr_utility.raise_error;
281 End lck;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |-----------------------------< convert_args >-----------------------------|
285 -- ----------------------------------------------------------------------------
286 Function convert_args
287 	(
288 	p_address_id                    in number,
289 	p_business_group_id             in number,
290 	p_person_id                     in number,
291 	p_date_from                     in date,
292 	p_primary_flag                  in varchar2,
293 	p_style                         in varchar2,
294 	p_address_line1                 in varchar2,
295 	p_address_line2                 in varchar2,
296 	p_address_line3                 in varchar2,
297 	p_address_type                  in varchar2,
298 	p_comments                      in long,
299 	p_country                       in varchar2,
300 	p_date_to                       in date,
301 	p_postal_code                   in varchar2,
302 	p_region_1                      in varchar2,
303 	p_region_2                      in varchar2,
304 	p_region_3                      in varchar2,
305 	p_telephone_number_1            in varchar2,
306 	p_telephone_number_2            in varchar2,
307 	p_telephone_number_3            in varchar2,
308 	p_town_or_city                  in varchar2,
309 	p_request_id                    in number,
310 	p_program_application_id        in number,
311 	p_program_id                    in number,
312 	p_program_update_date           in date,
313 	p_addr_attribute_category       in varchar2,
314 	p_addr_attribute1               in varchar2,
315 	p_addr_attribute2               in varchar2,
316 	p_addr_attribute3               in varchar2,
317 	p_addr_attribute4               in varchar2,
318 	p_addr_attribute5               in varchar2,
319 	p_addr_attribute6               in varchar2,
320 	p_addr_attribute7               in varchar2,
321 	p_addr_attribute8               in varchar2,
322 	p_addr_attribute9               in varchar2,
323 	p_addr_attribute10              in varchar2,
324 	p_addr_attribute11              in varchar2,
325 	p_addr_attribute12              in varchar2,
326 	p_addr_attribute13              in varchar2,
327 	p_addr_attribute14              in varchar2,
328 	p_addr_attribute15              in varchar2,
329 	p_addr_attribute16              in varchar2,
330 	p_addr_attribute17              in varchar2,
331 	p_addr_attribute18              in varchar2,
332 	p_addr_attribute19              in varchar2,
333 	p_addr_attribute20              in varchar2,
334 	p_object_version_number         in number
335 	)
336 	Return g_rec_type is
337 --
338   l_rec	  g_rec_type;
339   l_proc  varchar2(72) := g_package||'convert_args';
340 --
341 Begin
342   --
343   hr_utility.set_location('Entering:'||l_proc, 5);
344   --
345   -- Convert arguments into local l_rec structure.
346   --
347   l_rec.address_id                       := p_address_id;
348   l_rec.business_group_id                := p_business_group_id;
349   l_rec.person_id                        := p_person_id;
350   l_rec.date_from                        := p_date_from;
351   l_rec.primary_flag                     := p_primary_flag;
352   l_rec.style                            := p_style;
353   l_rec.address_line1                    := p_address_line1;
354   l_rec.address_line2                    := p_address_line2;
355   l_rec.address_line3                    := p_address_line3;
356   l_rec.address_type                     := p_address_type;
357   l_rec.comments                         := p_comments;
358   l_rec.country                          := p_country;
359   l_rec.date_to                          := p_date_to;
360   l_rec.postal_code                      := p_postal_code;
361   l_rec.region_1                         := p_region_1;
362   l_rec.region_2                         := p_region_2;
363   l_rec.region_3                         := p_region_3;
364   l_rec.telephone_number_1               := p_telephone_number_1;
365   l_rec.telephone_number_2               := p_telephone_number_2;
366   l_rec.telephone_number_3               := p_telephone_number_3;
367   l_rec.town_or_city                     := p_town_or_city;
368   l_rec.request_id                       := p_request_id;
369   l_rec.program_application_id           := p_program_application_id;
370   l_rec.program_id                       := p_program_id;
371   l_rec.program_update_date              := p_program_update_date;
372   l_rec.addr_attribute_category          := p_addr_attribute_category;
373   l_rec.addr_attribute1                  := p_addr_attribute1;
374   l_rec.addr_attribute2                  := p_addr_attribute2;
375   l_rec.addr_attribute3                  := p_addr_attribute3;
376   l_rec.addr_attribute4                  := p_addr_attribute4;
377   l_rec.addr_attribute5                  := p_addr_attribute5;
378   l_rec.addr_attribute6                  := p_addr_attribute6;
379   l_rec.addr_attribute7                  := p_addr_attribute7;
380   l_rec.addr_attribute8                  := p_addr_attribute8;
381   l_rec.addr_attribute9                  := p_addr_attribute9;
382   l_rec.addr_attribute10                 := p_addr_attribute10;
383   l_rec.addr_attribute11                 := p_addr_attribute11;
384   l_rec.addr_attribute12                 := p_addr_attribute12;
385   l_rec.addr_attribute13                 := p_addr_attribute13;
386   l_rec.addr_attribute14                 := p_addr_attribute14;
387   l_rec.addr_attribute15                 := p_addr_attribute15;
388   l_rec.addr_attribute16                 := p_addr_attribute16;
389   l_rec.addr_attribute17                 := p_addr_attribute17;
390   l_rec.addr_attribute18                 := p_addr_attribute18;
391   l_rec.addr_attribute19                 := p_addr_attribute19;
392   l_rec.addr_attribute20                 := p_addr_attribute20;
393   l_rec.object_version_number            := p_object_version_number;
394   --
395   -- Return the plsql record structure.
396   --
397   hr_utility.set_location(' Leaving:'||l_proc, 10);
398   Return(l_rec);
399 --
400 End convert_args;
401 --
402 end per_kad_shd;