DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TCN_INS

Source


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