DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_SNP_INS

Source


1 Package Body hr_snp_ins as
2 /* $Header: hrsnprhi.pkb 120.0 2005/05/31 02:52:28 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_snp_ins.';  -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_snapshot_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_snapshot_id  in  number) is
20 --
21   l_proc       varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24   hr_utility.set_location('Entering:'||l_proc, 10);
25   --
26   hr_snp_ins.g_snapshot_id_i := p_snapshot_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;--
30 --
31 -- ----------------------------------------------------------------------------
32 -- |------------------------------< insert_dml >------------------------------|
33 -- ----------------------------------------------------------------------------
34 -- {Start Of Comments}
35 --
36 -- Description:
37 --   This procedure controls the actual dml insert logic. The processing of
38 --   this procedure are as follows:
39 --   1) Initialise the object_version_number to 1 if the object_version_number
40 --      is defined as an attribute for this entity.
41 --   2) To set and unset the g_api_dml status as required (as we are about to
42 --      perform dml).
43 --   3) To insert the row into the schema.
44 --   4) To trap any constraint violations that may have occurred.
45 --   5) To raise any other errors.
46 --
47 -- Prerequisites:
48 --   This is an internal private procedure which must be called from the ins
49 --   procedure and must have all mandatory attributes set (except the
50 --   object_version_number which is initialised within this procedure).
51 --
52 -- In Parameters:
53 --   A Pl/Sql record structre.
54 --
55 -- Post Success:
56 --   The specified row will be inserted into the schema.
57 --
58 -- Post Failure:
59 --   On the insert dml failure it is important to note that we always reset the
60 --   g_api_dml status to false.
61 --   If a check, unique or parent integrity constraint violation is raised the
62 --   constraint_error procedure will be called.
63 --   If any other error is reported, the error will be raised after the
64 --   g_api_dml status is reset.
65 --
66 -- Developer Implementation Notes:
67 --   None.
68 --
69 -- Access Status:
70 --   Internal Row Handler Use Only.
71 --
72 -- {End Of Comments}
73 -- ----------------------------------------------------------------------------
74 --
75 -- ----------------------------------------------------------------------------
76 Procedure insert_dml
77   (p_rec in out nocopy hr_snp_shd.g_rec_type
78   ) is
79 --
80   l_proc  varchar2(72) := g_package||'insert_dml';
81 --
82 Begin
83   hr_utility.set_location('Entering:'||l_proc, 5);
84   p_rec.object_version_number := 1;  -- Initialise the object version
85   --
86   --
87   --
88   -- Insert the row into: hr_transaction_snapshot
89   --
90   insert into hr_transaction_snapshot
91       (snapshot_id
92       ,object_version_number
93       ,document
94       ,object_name
95       ,object_identifier
96       )
97   Values
98     (p_rec.snapshot_id
99     ,p_rec.object_version_number
100     ,p_rec.document
101     ,p_rec.object_name
102     ,p_rec.object_identifier
103 
104     );
105   --
106   --
107   --
108   hr_utility.set_location(' Leaving:'||l_proc, 10);
109 Exception
110   When hr_api.check_integrity_violated Then
111     -- A check constraint has been violated
112     --
113     hr_snp_shd.constraint_error
114       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115   When hr_api.parent_integrity_violated Then
116     -- Parent integrity has been violated
117     --
118     hr_snp_shd.constraint_error
119       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120   When hr_api.unique_integrity_violated Then
121     -- Unique integrity has been violated
122     --
123     hr_snp_shd.constraint_error
124       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
125   When Others Then
126     --
127     Raise;
128 End insert_dml;
129 -- |------------------------------< pre_insert >------------------------------|
130 -- ----------------------------------------------------------------------------
131 -- {Start Of Comments}
132 --
133 -- Description:
134 --   This private procedure contains any processing which is required before
135 --   the insert dml. Presently, if the entity has a corresponding primary
136 --   key which is maintained by an associating sequence, the primary key for
137 --   the entity will be populated with the next sequence value in
138 --   preparation for the insert dml.
139 --
140 -- Prerequisites:
141 --   This is an internal procedure which is called from the ins procedure.
142 --
143 -- In Parameters:
144 --   A Pl/Sql record structure.
145 --
146 -- Post Success:
147 --   Processing continues.
148 --
149 -- Post Failure:
150 --   If an error has occurred, an error message and exception will be raised
151 --   but not handled.
152 --
153 -- Developer Implementation Notes:
154 --   Any pre-processing required before the insert dml is issued should be
155 --   coded within this procedure. As stated above, a good example is the
156 --   generation of a primary key number via a corresponding sequence.
157 --   It is important to note that any 3rd party maintenance should be reviewed
158 --   before placing in this procedure.
159 --
160 -- Access Status:
161 --   Internal Row Handler Use Only.
162 --
163 -- {End Of Comments}
164 -- ----------------------------------------------------------------------------
165 Procedure pre_insert
166   (p_rec  in out nocopy hr_snp_shd.g_rec_type
167   ) is
168 --
169   Cursor C_Sel1 is select hr_transaction_snapshot_s.nextval from sys.dual;
170 --
171   Cursor C_Sel2 is
172     Select null
173       from hr_transaction_snapshot
174      where snapshot_id =
175              hr_snp_ins.g_snapshot_id_i;
176 --
177   l_proc   varchar2(72) := g_package||'pre_insert';
178   l_exists varchar2(1);
179 --
180 Begin
181   hr_utility.set_location('Entering:'||l_proc, 5);
182   --
183   If (hr_snp_ins.g_snapshot_id_i is not null) Then
184     --
185     -- Verify registered primary key values not already in use
186     --
187     Open C_Sel2;
188     Fetch C_Sel2 into l_exists;
189     If C_Sel2%found Then
190        Close C_Sel2;
191        --
192        -- The primary key values are already in use.
193        --
194        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
195        fnd_message.set_token('TABLE_NAME','hr_transaction_snapshot');
196        fnd_message.raise_error;
197     End If;
198     Close C_Sel2;
199     --
200     -- Use registered key values and clear globals
201     --
202     p_rec.snapshot_id :=
203       hr_snp_ins.g_snapshot_id_i;
204     hr_snp_ins.g_snapshot_id_i := null;
205   Else
206     --
207     -- No registerd key values, so select the next sequence number
208     --
209     --
210     -- Select the next sequence number
211     --
212     Open C_Sel1;
213     Fetch C_Sel1 Into p_rec.snapshot_id;
214     Close C_Sel1;
215   End If;
216   --
217   hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End pre_insert;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |-----------------------------< post_insert >------------------------------|
222 -- ----------------------------------------------------------------------------
223 -- {Start Of Comments}
224 --
225 -- Description:
226 --   This private procedure contains any processing which is required after
227 --   the insert dml.
228 --
229 -- Prerequisites:
230 --   This is an internal procedure which is called from the ins procedure.
231 --
232 -- In Parameters:
233 --   A Pl/Sql record structre.
234 --
235 -- Post Success:
236 --   Processing continues.
237 --
238 -- Post Failure:
239 --   If an error has occurred, an error message and exception will be raised
240 --   but not handled.
241 --
242 -- Developer Implementation Notes:
243 --   Any post-processing required after the insert dml is issued should be
244 --   coded within this procedure. It is important to note that any 3rd party
245 --   maintenance should be reviewed before placing in this procedure.
246 --
247 -- Access Status:
248 --   Internal Row Handler Use Only.
249 --
250 -- {End Of Comments}
251 -- ----------------------------------------------------------------------------
252 Procedure post_insert
253   (p_rec                          in hr_snp_shd.g_rec_type
254   ) is
255 --
256   l_proc  varchar2(72) := g_package||'post_insert';
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   begin
261     --
262     /*hr_snp_rki.after_insert
263       (p_snapshot_id
264       => p_rec.snapshot_id
265       ,p_object_version_number
266       => p_rec.object_version_number
267       ,p_access_key
268       => p_rec.access_key
269       ,p_document
270       => p_rec.document
271       );*/
272 
273       null;
274     --
275   exception
276     --
277     when hr_api.cannot_find_prog_unit then
278       --
279       hr_api.cannot_find_prog_unit_error
280         (p_module_name => 'HR_TRANSACTION_SNAPSHOT'
281         ,p_hook_type   => 'AI');
282       --
283   end;
284   --
285   hr_utility.set_location(' Leaving:'||l_proc, 10);
286 End post_insert;
287 --
288 -- ----------------------------------------------------------------------------
289 -- |---------------------------------< ins >----------------------------------|
290 -- ----------------------------------------------------------------------------
291 --
292 -- ----------------------------------------------------------------------------
293 Procedure ins
294   (p_rec                          in out nocopy hr_snp_shd.g_rec_type
295   ) is
296 --
297   l_proc  varchar2(72) := g_package||'ins';
298 --
299 Begin
300   hr_utility.set_location('Entering:'||l_proc, 5);
301   --
302   -- Call the supporting insert validate operations
303   --
304   hr_snp_bus.insert_validate
305      (p_rec
306      );
307   --
308   -- Call to raise any errors on multi-message list
309   hr_multi_message.end_validation_set;
310   --
311   -- Call the supporting pre-insert operation
312   --
313   hr_snp_ins.pre_insert(p_rec);
314   --
315   -- Insert the row
316   --
317   hr_snp_ins.insert_dml(p_rec);
318   --
319   -- Call the supporting post-insert operation
320   --
321   hr_snp_ins.post_insert
322      (p_rec
323      );
324   --
325   -- Call to raise any errors on multi-message list
326   hr_multi_message.end_validation_set;
327   --
328   hr_utility.set_location('Leaving:'||l_proc, 20);
329 end ins;
330 -- |---------------------------------< ins >----------------------------------|
331 -- ----------------------------------------------------------------------------
332 Procedure ins
333   (p_document                          in  clob
334   ,p_snapshot_id                       out nocopy number
335   ,p_object_version_number             out nocopy number
336   ,p_object_name                       in  varchar2
337   ,p_object_identifier                 in  varchar2
338 
339   ) is
340 --
341   l_rec   hr_snp_shd.g_rec_type;
342   l_proc  varchar2(72) := g_package||'ins';
343 --
344 Begin
345   hr_utility.set_location('Entering:'||l_proc, 5);
346   --
347   -- Call conversion function to turn arguments into the
348   -- p_rec structure.
349   --
350   l_rec :=
351   hr_snp_shd.convert_args
352     (null
353     ,null
354     ,p_document
355     ,p_object_name
356     ,p_object_identifier
357     );
358   --
359   -- Having converted the arguments into the hr_snp_rec
360   -- plsql record structure we call the corresponding record business process.
361   --
362   hr_snp_ins.ins
363      (l_rec
364      );
365   --
366   -- As the primary key argument(s)
367   -- are specified as an OUT's we must set these values.
368   --
369   p_snapshot_id := l_rec.snapshot_id;
370   p_object_version_number := l_rec.object_version_number;
371   --
372   hr_utility.set_location(' Leaving:'||l_proc, 10);
373 End ins;
374 --
375 end hr_snp_ins;