DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TWN_INS

Source


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