1 Package Body hr_tip_ins as
2 /* $Header: hrtiprhi.pkb 120.1 2011/04/28 10:49:21 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_tip_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_tip_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_item_tab_pages
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_ITEM_TAB_PAGES',
76 p_ref_entity_info => PER_RIC_PKG.ref_entity_tbl(
77 PER_RIC_PKG.ref_info_rec('HR_TEMPLATE_ITEMS_B', PER_RIC_PKG.column_info_tbl(
78 PER_RIC_PKG.col_info_rec('TEMPLATE_ITEM_ID',NULL,P_REC.TEMPLATE_ITEM_ID,NULL))),
79 PER_RIC_PKG.ref_info_rec('HR_TEMPLATE_TAB_PAGES_B', PER_RIC_PKG.column_info_tbl(
80 PER_RIC_PKG.col_info_rec('TEMPLATE_TAB_PAGE_ID',NULL,P_REC.TEMPLATE_TAB_PAGE_ID,NULL)))
81 ),
82 p_ref_type => 'INS');
83
84 END;
85 --
86 -- Code Ends Here.
87 --
88
89 insert into hr_template_item_tab_pages
90 (template_item_tab_page_id
91 ,object_version_number
92 ,template_item_id
93 ,template_tab_page_id
94 )
95 Values
96 (p_rec.template_item_tab_page_id
97 ,p_rec.object_version_number
98 ,p_rec.template_item_id
99 ,p_rec.template_tab_page_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_tip_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_tip_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_tip_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_tip_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_item_tab_pages_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_tab_page_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_tip_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_tip_rki.after_insert
227 (p_template_item_tab_page_id
228 => p_rec.template_item_tab_page_id
229 ,p_object_version_number
230 => p_rec.object_version_number
231 ,p_template_item_id
232 => p_rec.template_item_id
233 ,p_template_tab_page_id
234 => p_rec.template_tab_page_id
235 );
236 --
237 exception
238 --
239 when hr_api.cannot_find_prog_unit then
240 --
241 hr_api.cannot_find_prog_unit_error
242 (p_module_name => 'HR_TEMPLATE_ITEM_TAB_PAGES'
243 ,p_hook_type => 'AI');
244 --
245 end;
246 --
247 hr_utility.set_location(' Leaving:'||l_proc, 10);
248 End post_insert;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |---------------------------------< ins >----------------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure ins
254 (p_rec in out nocopy hr_tip_shd.g_rec_type
255 ) is
256 --
257 l_proc varchar2(72) := g_package||'ins';
258 --
259 Begin
260 hr_utility.set_location('Entering:'||l_proc, 5);
261 --
262 -- Call the supporting insert validate operations
263 --
264 hr_tip_bus.insert_validate
265 (p_rec
266 );
267 --
268 -- Call the supporting pre-insert operation
269 --
270 hr_tip_ins.pre_insert(p_rec);
271 --
272 -- Insert the row
273 --
274 hr_tip_ins.insert_dml(p_rec);
275 --
276 -- Call the supporting post-insert operation
277 --
278 hr_tip_ins.post_insert
279 (p_rec
280 );
281 --
282 hr_utility.set_location('Leaving:'||l_proc, 20);
283 end ins;
284 --
285 -- ----------------------------------------------------------------------------
286 -- |---------------------------------< ins >----------------------------------|
287 -- ----------------------------------------------------------------------------
288 Procedure ins
289 (p_template_item_id in number
290 ,p_template_tab_page_id in number
291 ,p_template_item_tab_page_id out nocopy number
292 ,p_object_version_number out nocopy number
293 ) is
294 --
295 l_rec hr_tip_shd.g_rec_type;
296 l_proc varchar2(72) := g_package||'ins';
297 --
298 Begin
299 hr_utility.set_location('Entering:'||l_proc, 5);
300 --
301 -- Call conversion function to turn arguments into the
302 -- p_rec structure.
303 --
304 l_rec :=
305 hr_tip_shd.convert_args
306 (null
307 ,null
308 ,p_template_item_id
309 ,p_template_tab_page_id
310 );
311 --
312 -- Having converted the arguments into the hr_tip_rec
313 -- plsql record structure we call the corresponding record business process.
314 --
315 hr_tip_ins.ins
316 (l_rec
317 );
318 --
319 -- As the primary key argument(s)
320 -- are specified as an OUT's we must set these values.
321 --
322 p_template_item_tab_page_id := l_rec.template_item_tab_page_id;
323 p_object_version_number := l_rec.object_version_number;
324 --
325 hr_utility.set_location(' Leaving:'||l_proc, 10);
326 End ins;
327 --
328 end hr_tip_ins;