DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TIM_INS

Source


1 Package Body hr_tim_ins as
2 /* $Header: hrtimrhi.pkb 120.1 2011/04/28 10:55:47 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_tim_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
54   (p_rec in out nocopy hr_tim_shd.g_rec_type
55   ) is
56 --
57   l_proc  varchar2(72) := g_package||'insert_dml';
58 --
59 Begin
60   hr_utility.set_location('Entering:'||l_proc, 5);
61   p_rec.object_version_number := 1;  -- Initialise the object version
62   --
63   --
64   --
65   -- Insert the row into: hr_template_items_b
66   --
67 
68 --
69 -- Added the following code as a part of Zero Downtime Patching Project.
70 -- Code Starts Here.
71 --
72 
73 BEGIN
74 	PER_RIC_PKG.chk_integrity (
75     p_entity_name		=>	'HR_TEMPLATE_ITEMS_B',
76     p_ref_entity_info   => PER_RIC_PKG.ref_entity_tbl(
77 							PER_RIC_PKG.ref_info_rec('HR_FORM_TEMPLATES_B', PER_RIC_PKG.column_info_tbl(
78                                                 PER_RIC_PKG.col_info_rec('FORM_TEMPLATE_ID',NULL,p_rec.form_template_id ,NULL))),
79 							PER_RIC_PKG.ref_info_rec('HR_FORM_ITEMS_B', PER_RIC_PKG.column_info_tbl(
80                                                 PER_RIC_PKG.col_info_rec('FORM_ITEM_ID',NULL,p_rec.form_item_id,NULL)))
81 							),
82     p_ref_type        	=>	'INS');
83 
84 END;
85 --
86 -- Code Ends Here.
87 --
88 
89   insert into hr_template_items_b
90       (template_item_id
91       ,object_version_number
92       ,form_template_id
93       ,form_item_id
94       )
95   Values
96     (p_rec.template_item_id
97     ,p_rec.object_version_number
98     ,p_rec.form_template_id
99     ,p_rec.form_item_id
100     );
101   --
102   --
103   --
104   hr_utility.set_location(' Leaving:'||l_proc, 10);
105 Exception
106   When hr_api.check_integrity_violated Then
107     -- A check constraint has been violated
108     --
109     hr_tim_shd.constraint_error
110       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111   When hr_api.parent_integrity_violated Then
112     -- Parent integrity has been violated
113     --
114     hr_tim_shd.constraint_error
115       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
116   When hr_api.unique_integrity_violated Then
117     -- Unique integrity has been violated
118     --
119     hr_tim_shd.constraint_error
120       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121   When Others Then
122     --
123     Raise;
124 End insert_dml;
125 --
126 -- ----------------------------------------------------------------------------
127 -- |------------------------------< pre_insert >------------------------------|
128 -- ----------------------------------------------------------------------------
129 -- {Start Of Comments}
130 --
131 -- Description:
132 --   This private procedure contains any processing which is required before
133 --   the insert dml. Presently, if the entity has a corresponding primary
134 --   key which is maintained by an associating sequence, the primary key for
135 --   the entity will be populated with the next sequence value in
136 --   preparation for the insert dml.
137 --
138 -- Prerequisites:
139 --   This is an internal procedure which is called from the ins procedure.
140 --
141 -- In Parameters:
142 --   A Pl/Sql record structre.
143 --
144 -- Post Success:
145 --   Processing continues.
146 --
147 -- Post Failure:
148 --   If an error has occurred, an error message and exception will be raised
149 --   but not handled.
150 --
151 -- Developer Implementation Notes:
152 --   Any pre-processing required before the insert dml is issued should be
153 --   coded within this procedure. As stated above, a good example is the
154 --   generation of a primary key number via a corresponding sequence.
155 --   It is important to note that any 3rd party maintenance should be reviewed
156 --   before placing in this procedure.
157 --
158 -- Access Status:
159 --   Internal Row Handler Use Only.
160 --
161 -- {End Of Comments}
162 -- ----------------------------------------------------------------------------
163 Procedure pre_insert
164   (p_rec  in out nocopy hr_tim_shd.g_rec_type
165   ) is
166 --
167   l_proc  varchar2(72) := g_package||'pre_insert';
168 --
169   Cursor C_Sel1 is select hr_template_items_b_s.nextval from sys.dual;
170 --
171 Begin
172   hr_utility.set_location('Entering:'||l_proc, 5);
173   --
174   --
175   -- Select the next sequence number
176   --
177   Open C_Sel1;
178   Fetch C_Sel1 Into p_rec.template_item_id;
179   Close C_Sel1;
180   --
181   hr_utility.set_location(' Leaving:'||l_proc, 10);
182 End pre_insert;
183 --
184 -- ----------------------------------------------------------------------------
185 -- |-----------------------------< post_insert >------------------------------|
186 -- ----------------------------------------------------------------------------
187 -- {Start Of Comments}
188 --
189 -- Description:
190 --   This private procedure contains any processing which is required after the
191 --   insert dml.
192 --
193 -- Prerequisites:
194 --   This is an internal procedure which is called from the ins procedure.
195 --
196 -- In Parameters:
197 --   A Pl/Sql record structre.
198 --
199 -- Post Success:
200 --   Processing continues.
201 --
202 -- Post Failure:
203 --   If an error has occurred, an error message and exception will be raised
204 --   but not handled.
205 --
206 -- Developer Implementation Notes:
207 --   Any post-processing required after the insert dml is issued should be
208 --   coded within this procedure. It is important to note that any 3rd party
209 --   maintenance should be reviewed before placing in this procedure.
210 --
211 -- Access Status:
212 --   Internal Row Handler Use Only.
213 --
214 -- {End Of Comments}
215 -- ----------------------------------------------------------------------------
216 Procedure post_insert
217   (p_rec                          in hr_tim_shd.g_rec_type
218   ) is
219 --
220   l_proc  varchar2(72) := g_package||'post_insert';
221 --
222 Begin
223   hr_utility.set_location('Entering:'||l_proc, 5);
224   begin
225     --
226     hr_tim_bus.chk_no_flex_segment_comb
227       (p_form_template_id       =>  p_rec.form_template_id
228       ,p_object_version_number  =>  p_rec.object_version_number
229       ,p_form_item_id           =>  p_rec.form_item_id
230       );
231     --
232     hr_tim_rki.after_insert
233       (p_template_item_id
234       => p_rec.template_item_id
235       ,p_object_version_number
236       => p_rec.object_version_number
237       ,p_form_template_id
238       => p_rec.form_template_id
239       ,p_form_item_id
240       => p_rec.form_item_id
241       );
242     --
243   exception
244     --
245     when hr_api.cannot_find_prog_unit then
246       --
247       hr_api.cannot_find_prog_unit_error
248         (p_module_name => 'HR_TEMPLATE_ITEMS_B'
249         ,p_hook_type   => 'AI');
250       --
251   end;
252   --
253   hr_utility.set_location(' Leaving:'||l_proc, 10);
254 End post_insert;
255 --
256 -- ----------------------------------------------------------------------------
257 -- |---------------------------------< ins >----------------------------------|
258 -- ----------------------------------------------------------------------------
259 Procedure ins
260   (p_rec                          in out nocopy hr_tim_shd.g_rec_type
261   ) is
262 --
263   l_proc  varchar2(72) := g_package||'ins';
264 --
265 Begin
266   hr_utility.set_location('Entering:'||l_proc, 5);
267   --
268   -- Call the supporting insert validate operations
269   --
270   hr_tim_bus.insert_validate
271      (p_rec
272      );
273   --
274   -- Call the supporting pre-insert operation
275   --
276   hr_tim_ins.pre_insert(p_rec);
277   --
278   -- Insert the row
279   --
280   hr_tim_ins.insert_dml(p_rec);
281   --
282   -- Call the supporting post-insert operation
283   --
284   hr_tim_ins.post_insert
285      (p_rec
286      );
287   --
288   hr_utility.set_location('Leaving:'||l_proc, 20);
289 end ins;
290 --
291 -- ----------------------------------------------------------------------------
292 -- |---------------------------------< ins >----------------------------------|
293 -- ----------------------------------------------------------------------------
294 Procedure ins
295   (p_form_template_id               in     number
296   ,p_form_item_id                   in     number
297   ,p_template_item_id                  out nocopy number
298   ,p_object_version_number             out nocopy number
299   ) is
300 --
301   l_rec	  hr_tim_shd.g_rec_type;
302   l_proc  varchar2(72) := g_package||'ins';
303 --
304 Begin
305   hr_utility.set_location('Entering:'||l_proc, 5);
306   --
307   -- Call conversion function to turn arguments into the
308   -- p_rec structure.
309   --
310   l_rec :=
311   hr_tim_shd.convert_args
312     (null
313     ,null
314     ,p_form_template_id
315     ,p_form_item_id
316     );
317   --
318   -- Having converted the arguments into the hr_tim_rec
319   -- plsql record structure we call the corresponding record business process.
320   --
321   hr_tim_ins.ins
322      (l_rec
323      );
324   --
325   -- As the primary key argument(s)
326   -- are specified as an OUT's we must set these values.
327   --
328   p_template_item_id := l_rec.template_item_id;
329   p_object_version_number := l_rec.object_version_number;
330   --
331   hr_utility.set_location(' Leaving:'||l_proc, 10);
332 End ins;
333 --
334 end hr_tim_ins;