DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_SSM_INS

Source


1 Package Body per_ssm_ins as
2 /* $Header: pessmrhi.pkb 120.0 2005/05/31 21:50:48 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_ssm_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To insert the row into the schema.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
27 --   This is an internal private procedure which must be called from the ins
28 --   procedure and must have all mandatory attributes set (except the
29 --   object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 --   On the insert dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   None.
47 --
48 -- Access Status:
49 --   Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy per_ssm_shd.g_rec_type) is
54 --
55   l_proc  varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58   hr_utility.set_location('Entering:'||l_proc, 5);
59   p_rec.object_version_number := 1;  -- Initialise the object version
60   --
61   per_ssm_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: per_salary_survey_mappings
64   --
65   insert into per_salary_survey_mappings
66   (	object_version_number,
67 	salary_survey_mapping_id,
68 	parent_id,
69 	parent_table_name,
70 	salary_survey_line_id,
71 	business_group_id,
72 	location_id,
73 	grade_id,
74 	company_organization_id,
75 	company_age_code,
76 	attribute_category,
77 	attribute1,
78 	attribute2,
79 	attribute3,
80 	attribute4,
81 	attribute5,
82 	attribute6,
83 	attribute7,
84 	attribute8,
85 	attribute9,
86 	attribute10,
87 	attribute11,
88 	attribute12,
89 	attribute13,
90 	attribute14,
91 	attribute15,
92 	attribute16,
93 	attribute17,
94 	attribute18,
95 	attribute19,
96 	attribute20
97   )
98   Values
99   (	p_rec.object_version_number,
100 	p_rec.salary_survey_mapping_id,
101 	p_rec.parent_id,
102 	p_rec.parent_table_name,
103 	p_rec.salary_survey_line_id,
104 	p_rec.business_group_id,
105 	p_rec.location_id,
106 	p_rec.grade_id,
107 	p_rec.company_organization_id,
108 	p_rec.company_age_code,
109 	p_rec.attribute_category,
110 	p_rec.attribute1,
111 	p_rec.attribute2,
112 	p_rec.attribute3,
113 	p_rec.attribute4,
114 	p_rec.attribute5,
115 	p_rec.attribute6,
116 	p_rec.attribute7,
117 	p_rec.attribute8,
118 	p_rec.attribute9,
119 	p_rec.attribute10,
120 	p_rec.attribute11,
121 	p_rec.attribute12,
122 	p_rec.attribute13,
123 	p_rec.attribute14,
124 	p_rec.attribute15,
125 	p_rec.attribute16,
126 	p_rec.attribute17,
127 	p_rec.attribute18,
128 	p_rec.attribute19,
129 	p_rec.attribute20
130   );
131   --
132   per_ssm_shd.g_api_dml := false;   -- Unset the api dml status
133   --
134   hr_utility.set_location(' Leaving:'||l_proc, 10);
135 Exception
136   When hr_api.check_integrity_violated Then
137     -- A check constraint has been violated
138     hr_utility.set_location(l_proc, 6);
139     per_ssm_shd.g_api_dml := false;   -- Unset the api dml status
140     per_ssm_shd.constraint_error
141       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
142   When hr_api.parent_integrity_violated Then
143   hr_utility.set_location(l_proc, 7);
144     -- Parent integrity has been violated
145     per_ssm_shd.g_api_dml := false;   -- Unset the api dml status
146     per_ssm_shd.constraint_error
147       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
148   When hr_api.unique_integrity_violated Then
149   hr_utility.set_location(l_proc, 8);
150     -- Unique integrity has been violated
151     per_ssm_shd.g_api_dml := false;   -- Unset the api dml status
152     per_ssm_shd.constraint_error
153       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
154   When Others Then
155   hr_utility.set_location(l_proc, 9);
156     per_ssm_shd.g_api_dml := false;   -- Unset the api dml status
157     Raise;
158 End insert_dml;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |------------------------------< pre_insert >------------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 --   This private procedure contains any processing which is required before
167 --   the insert dml. Presently, if the entity has a corresponding primary
168 --   key which is maintained by an associating sequence, the primary key for
169 --   the entity will be populated with the next sequence value in
170 --   preparation for the insert dml.
171 --
172 -- Prerequisites:
173 --   This is an internal procedure which is called from the ins procedure.
174 --
175 -- In Parameters:
176 --   A Pl/Sql record structre.
177 --
178 -- Post Success:
179 --   Processing continues.
180 --
181 -- Post Failure:
182 --   If an error has occurred, an error message and exception will be raised
183 --   but not handled.
184 --
185 -- Developer Implementation Notes:
186 --   Any pre-processing required before the insert dml is issued should be
187 --   coded within this procedure. As stated above, a good example is the
188 --   generation of a primary key number via a corresponding sequence.
189 --   It is important to note that any 3rd party maintenance should be reviewed
190 --   before placing in this procedure.
191 --
192 -- Access Status:
193 --   Internal Row Handler Use Only.
194 --
195 -- {End Of Comments}
196 -- ----------------------------------------------------------------------------
197 Procedure pre_insert(p_rec  in out nocopy per_ssm_shd.g_rec_type) is
198 --
199   l_proc  varchar2(72) := g_package||'pre_insert';
200 --
201   Cursor C_Sel1 is select per_salary_survey_mappings_s.nextval from sys.dual;
202 --
203 Begin
204   hr_utility.set_location('Entering:'||l_proc, 5);
205   --
206   --
207   -- Select the next sequence number
208   --
209   Open C_Sel1;
210   Fetch C_Sel1 Into p_rec.salary_survey_mapping_id;
211   Close C_Sel1;
212   --
213   hr_utility.set_location(' Leaving:'||l_proc, 10);
214 End pre_insert;
215 --
216 -- ----------------------------------------------------------------------------
217 -- |-----------------------------< post_insert >------------------------------|
218 -- ----------------------------------------------------------------------------
219 -- {Start Of Comments}
220 --
221 -- Description:
222 --   This private procedure contains any processing which is required after the
223 --   insert dml.
224 --
225 -- Prerequisites:
226 --   This is an internal procedure which is called from the ins procedure.
227 --
228 -- In Parameters:
229 --   A Pl/Sql record structre.
230 --
231 -- Post Success:
232 --   Processing continues.
233 --
234 -- Post Failure:
235 --   If an error has occurred, an error message and exception will be raised
236 --   but not handled.
237 --
238 -- Developer Implementation Notes:
239 --   Any post-processing required after the insert dml is issued should be
240 --   coded within this procedure. It is important to note that any 3rd party
241 --   maintenance should be reviewed before placing in this procedure.
242 --
243 -- Access Status:
244 --   Internal Row Handler Use Only.
245 --
246 -- {End Of Comments}
247 -- ----------------------------------------------------------------------------
248 Procedure post_insert(p_rec            in per_ssm_shd.g_rec_type,
249                       p_effective_date in date) is
250 --
251   l_proc  varchar2(72) := g_package||'post_insert';
252 --
253 Begin
254   hr_utility.set_location('Entering:'||l_proc, 5);
255   --
256   begin
257     per_ssm_rki.after_insert
258     (
259     p_object_version_number        => p_rec.object_version_number,
260     p_salary_survey_mapping_id     => p_rec.salary_survey_mapping_id ,
261     p_parent_id                    => p_rec.parent_id,
262     p_parent_table_name            => p_rec.parent_table_name,
263     p_salary_survey_line_id        => p_rec.salary_survey_line_id,
264     p_business_group_id            => p_rec.business_group_id,
265     p_location_id                  => p_rec.location_id,
266     p_grade_id                     => p_rec.grade_id,
267     p_company_organization_id      => p_rec.company_organization_id,
268     p_company_age_code             => p_rec.company_age_code,
269     p_attribute_category           => p_rec.attribute_category,
270     p_attribute1                   => p_rec.attribute1,
271     p_attribute2                   => p_rec.attribute2,
272     p_attribute3                   => p_rec.attribute3,
273     p_attribute4                   => p_rec.attribute4,
274     p_attribute5                   => p_rec.attribute5,
275     p_attribute6                   => p_rec.attribute6,
276     p_attribute7                   => p_rec.attribute7,
277     p_attribute8                   => p_rec.attribute8,
278     p_attribute9                   => p_rec.attribute9,
279     p_attribute10                  => p_rec.attribute10,
280     p_attribute11                  => p_rec.attribute11,
281     p_attribute12                  => p_rec.attribute12,
282     p_attribute13                  => p_rec.attribute13,
283     p_attribute14                  => p_rec.attribute14,
284     p_attribute15                  => p_rec.attribute15,
285     p_attribute16                  => p_rec.attribute16,
286     p_attribute17                  => p_rec.attribute17,
287     p_attribute18                  => p_rec.attribute18,
288     p_attribute19                  => p_rec.attribute19,
289     p_attribute20                  => p_rec.attribute20,
290     p_effective_date		   => p_effective_date
291     );
292   --
293   exception
294     when hr_api.cannot_find_prog_unit then
295       --
296       hr_api.cannot_find_prog_unit_error
297 	(p_module_name => 'PER_SALARY_SURVEY_MAPPINGS'
298 	,p_hook_type   => 'AI'
299 	);
300   end;
301 --
302   hr_utility.set_location(' Leaving:'||l_proc, 10);
303 End post_insert;
304 --
305 -- ----------------------------------------------------------------------------
306 -- |---------------------------------< ins >----------------------------------|
307 -- ----------------------------------------------------------------------------
308 Procedure ins
309   (
310   p_rec            in out nocopy per_ssm_shd.g_rec_type,
311   p_effective_date in     date
312   ) is
313 --
314   l_proc  varchar2(72) := g_package||'ins';
315 --
316 Begin
317   hr_utility.set_location('Entering:'||l_proc, 5);
318   --
319   -- Call the supporting insert validate operations
320   --
321   per_ssm_bus.insert_validate(p_rec, p_effective_date);
322   --
323   -- Call the supporting pre-insert operation
324   --
325   pre_insert(p_rec);
326   --
327   -- Insert the row
328   --
329   insert_dml(p_rec);
330   --
331   -- Call the supporting post-insert operation
332   --
333   post_insert(p_rec,p_effective_date);
334 end ins;
335 --
336 -- ----------------------------------------------------------------------------
337 -- |---------------------------------< ins >----------------------------------|
338 -- ----------------------------------------------------------------------------
339 Procedure ins
340   (
341   p_object_version_number        out nocopy number,
342   p_salary_survey_mapping_id     out nocopy number,
343   p_parent_id                    in number,
344   p_parent_table_name            in varchar2,
345   p_salary_survey_line_id        in number,
346   p_business_group_id            in number,
347   p_location_id                  in number           default null,
348   p_grade_id                     in number           default null,
349   p_company_organization_id      in number           default null,
350   p_company_age_code             in varchar2         default null,
351   p_attribute_category           in varchar2         default null,
352   p_attribute1                   in varchar2         default null,
353   p_attribute2                   in varchar2         default null,
354   p_attribute3                   in varchar2         default null,
355   p_attribute4                   in varchar2         default null,
356   p_attribute5                   in varchar2         default null,
357   p_attribute6                   in varchar2         default null,
358   p_attribute7                   in varchar2         default null,
359   p_attribute8                   in varchar2         default null,
360   p_attribute9                   in varchar2         default null,
361   p_attribute10                  in varchar2         default null,
362   p_attribute11                  in varchar2         default null,
363   p_attribute12                  in varchar2         default null,
364   p_attribute13                  in varchar2         default null,
365   p_attribute14                  in varchar2         default null,
366   p_attribute15                  in varchar2         default null,
367   p_attribute16                  in varchar2         default null,
368   p_attribute17                  in varchar2         default null,
369   p_attribute18                  in varchar2         default null,
370   p_attribute19                  in varchar2         default null,
371   p_attribute20                  in varchar2         default null,
372   p_effective_date		 in date
373   ) is
374 --
375   l_rec	  per_ssm_shd.g_rec_type;
376   l_proc  varchar2(72) := g_package||'ins';
377 --
378 Begin
379   hr_utility.set_location('Entering:'||l_proc, 5);
380   --
381   -- Call conversion function to turn arguments into the
382   -- p_rec structure.
383   --
384   l_rec :=
385   per_ssm_shd.convert_args
386   (
387   null,
388   null,
389   p_parent_id,
390   p_parent_table_name,
391   p_salary_survey_line_id,
392   p_business_group_id,
393   p_location_id,
394   p_grade_id,
395   p_company_organization_id,
396   p_company_age_code,
397   p_attribute_category,
398   p_attribute1,
399   p_attribute2,
400   p_attribute3,
401   p_attribute4,
402   p_attribute5,
403   p_attribute6,
404   p_attribute7,
405   p_attribute8,
406   p_attribute9,
407   p_attribute10,
408   p_attribute11,
409   p_attribute12,
410   p_attribute13,
411   p_attribute14,
412   p_attribute15,
413   p_attribute16,
414   p_attribute17,
415   p_attribute18,
416   p_attribute19,
417   p_attribute20
418   );
419   --
420   -- Having converted the arguments into the per_ssm_rec
421   -- plsql record structure we call the corresponding record business process.
422   --
423   ins(l_rec, p_effective_date);
424   --
425   -- As the primary key argument(s)
426   -- are specified as an OUT's we must set these values.
427   --
428   p_salary_survey_mapping_id := l_rec.salary_survey_mapping_id;
429   p_object_version_number := l_rec.object_version_number;
430   --
431   hr_utility.set_location(' Leaving:'||l_proc, 10);
432 End ins;
433 --
434 end per_ssm_ins;