DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TIM_INS

Source


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