DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TIC_INS

Source


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