1 Package Body hr_fim_ins as
2 /* $Header: hrfimrhi.pkb 115.5 2002/12/03 11:18:58 hjonnala noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_fim_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_fim_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_form_items_b
66 --
67 insert into hr_form_items_b
68 (form_item_id
69 ,object_version_number
70 ,application_id
71 ,form_id
72 ,form_canvas_id
73 ,full_item_name
74 ,item_type
75 ,form_tab_page_id
76 ,radio_button_name
77 ,required_override
78 ,form_tab_page_id_override
79 ,visible_override
80 )
81 Values
82 (p_rec.form_item_id
83 ,p_rec.object_version_number
84 ,p_rec.application_id
85 ,p_rec.form_id
86 ,p_rec.form_canvas_id
87 ,p_rec.full_item_name
88 ,p_rec.item_type
89 ,p_rec.form_tab_page_id
90 ,p_rec.radio_button_name
91 ,p_rec.required_override
92 ,p_rec.form_tab_page_id_override
93 ,p_rec.visible_override
94 );
95 --
96 --
97 --
98 hr_utility.set_location(' Leaving:'||l_proc, 10);
99 Exception
100 When hr_api.check_integrity_violated Then
101 -- A check constraint has been violated
102 --
103 hr_fim_shd.constraint_error
104 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105 When hr_api.parent_integrity_violated Then
106 -- Parent integrity has been violated
107 --
108 hr_fim_shd.constraint_error
109 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110 When hr_api.unique_integrity_violated Then
111 -- Unique integrity has been violated
112 --
113 hr_fim_shd.constraint_error
114 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115 When Others Then
116 --
117 Raise;
118 End insert_dml;
119 --
120 -- ----------------------------------------------------------------------------
121 -- |------------------------------< pre_insert >------------------------------|
122 -- ----------------------------------------------------------------------------
123 -- {Start Of Comments}
124 --
125 -- Description:
126 -- This private procedure contains any processing which is required before
127 -- the insert dml. Presently, if the entity has a corresponding primary
128 -- key which is maintained by an associating sequence, the primary key for
129 -- the entity will be populated with the next sequence value in
130 -- preparation for the insert dml.
131 --
132 -- Prerequisites:
133 -- This is an internal procedure which is called from the ins procedure.
134 --
135 -- In Parameters:
136 -- A Pl/Sql record structre.
137 --
138 -- Post Success:
139 -- Processing continues.
140 --
141 -- Post Failure:
142 -- If an error has occurred, an error message and exception will be raised
143 -- but not handled.
144 --
145 -- Developer Implementation Notes:
146 -- Any pre-processing required before the insert dml is issued should be
147 -- coded within this procedure. As stated above, a good example is the
148 -- generation of a primary key number via a corresponding sequence.
149 -- It is important to note that any 3rd party maintenance should be reviewed
150 -- before placing in this procedure.
151 --
152 -- Access Status:
153 -- Internal Row Handler Use Only.
154 --
155 -- {End Of Comments}
156 -- ----------------------------------------------------------------------------
157 Procedure pre_insert
158 (p_rec in out nocopy hr_fim_shd.g_rec_type
159 ) is
160 --
161 l_proc varchar2(72) := g_package||'pre_insert';
162 --
163 Cursor C_Sel1 is select hr_form_items_b_s.nextval from sys.dual;
164 --
165 Begin
166 hr_utility.set_location('Entering:'||l_proc, 5);
167 --
168 --
169 -- Select the next sequence number
170 --
171 Open C_Sel1;
172 Fetch C_Sel1 Into p_rec.form_item_id;
173 Close C_Sel1;
174 --
175 hr_utility.set_location(' Leaving:'||l_proc, 10);
176 End pre_insert;
177 --
178 -- ----------------------------------------------------------------------------
179 -- |-----------------------------< post_insert >------------------------------|
180 -- ----------------------------------------------------------------------------
181 -- {Start Of Comments}
182 --
183 -- Description:
184 -- This private procedure contains any processing which is required after the
185 -- insert dml.
186 --
187 -- Prerequisites:
188 -- This is an internal procedure which is called from the ins procedure.
189 --
190 -- In Parameters:
191 -- A Pl/Sql record structre.
192 --
193 -- Post Success:
194 -- Processing continues.
195 --
196 -- Post Failure:
197 -- If an error has occurred, an error message and exception will be raised
198 -- but not handled.
199 --
200 -- Developer Implementation Notes:
201 -- Any post-processing required after the insert dml is issued should be
202 -- coded within this procedure. It is important to note that any 3rd party
203 -- maintenance should be reviewed before placing in this procedure.
204 --
205 -- Access Status:
206 -- Internal Row Handler Use Only.
207 --
208 -- {End Of Comments}
209 -- ----------------------------------------------------------------------------
210 Procedure post_insert
211 (p_effective_date in date
212 ,p_rec in hr_fim_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_fim_rki.after_insert
222 (p_effective_date => p_effective_date
223 ,p_form_item_id
224 => p_rec.form_item_id
225 ,p_object_version_number
226 => p_rec.object_version_number
227 ,p_application_id
228 => p_rec.application_id
229 ,p_form_id
230 => p_rec.form_id
231 ,p_form_canvas_id
232 => p_rec.form_canvas_id
233 ,p_full_item_name
234 => p_rec.full_item_name
235 ,p_item_type
236 => p_rec.item_type
237 ,p_form_tab_page_id
238 => p_rec.form_tab_page_id
239 ,p_radio_button_name
240 => p_rec.radio_button_name
241 ,p_required_override
242 => p_rec.required_override
243 ,p_form_tab_page_id_override
244 => p_rec.form_tab_page_id_override
245 ,p_visible_override
246 => p_rec.visible_override
247 );
248 --
249 exception
250 --
251 when hr_api.cannot_find_prog_unit then
252 --
253 hr_api.cannot_find_prog_unit_error
254 (p_module_name => 'HR_FORM_ITEMS_B'
255 ,p_hook_type => 'AI');
256 --
257 end;
258 --
259 hr_utility.set_location(' Leaving:'||l_proc, 10);
260 End post_insert;
261 --
262 -- ----------------------------------------------------------------------------
263 -- |---------------------------------< ins >----------------------------------|
264 -- ----------------------------------------------------------------------------
265 Procedure ins
266 (p_effective_date in date
267 ,p_rec in out nocopy hr_fim_shd.g_rec_type
268 ) is
269 --
270 l_proc varchar2(72) := g_package||'ins';
271 --
272 Begin
273 hr_utility.set_location('Entering:'||l_proc, 5);
274 --
275 -- Call the supporting insert validate operations
276 --
277 hr_fim_bus.insert_validate
278 (p_effective_date
279 ,p_rec
280 );
281 --
282 -- Call the supporting pre-insert operation
283 --
284 hr_fim_ins.pre_insert(p_rec);
285 --
286 -- Insert the row
287 --
288 hr_fim_ins.insert_dml(p_rec);
289 --
290 -- Call the supporting post-insert operation
291 --
292 hr_fim_ins.post_insert
293 (p_effective_date
294 ,p_rec
295 );
296 --
297 hr_utility.set_location('Leaving:'||l_proc, 20);
298 end ins;
299 --
300 -- ----------------------------------------------------------------------------
301 -- |---------------------------------< ins >----------------------------------|
302 -- ----------------------------------------------------------------------------
303 Procedure ins
304 (p_effective_date in date
305 ,p_application_id in number
306 ,p_form_id in number
307 ,p_form_canvas_id in number
308 ,p_full_item_name in varchar2
309 ,p_item_type in varchar2
310 ,p_form_tab_page_id in number default null
311 ,p_radio_button_name in varchar2 default null
312 ,p_required_override in number default null
313 ,p_form_tab_page_id_override in number default null
314 ,p_visible_override in number default null
315 ,p_form_item_id out nocopy number
316 ,p_object_version_number out nocopy number
317 ) is
318 --
319 l_rec hr_fim_shd.g_rec_type;
320 l_proc varchar2(72) := g_package||'ins';
321 --
322 Begin
323 hr_utility.set_location('Entering:'||l_proc, 5);
324 --
325 -- Call conversion function to turn arguments into the
326 -- p_rec structure.
327 --
328 l_rec :=
329 hr_fim_shd.convert_args
330 (null
331 ,null
332 ,p_application_id
333 ,p_form_id
334 ,p_form_canvas_id
335 ,p_full_item_name
336 ,p_item_type
337 ,p_form_tab_page_id
338 ,p_radio_button_name
339 ,p_required_override
340 ,p_form_tab_page_id_override
341 ,p_visible_override
342 );
343 --
344 -- Having converted the arguments into the hr_fim_rec
345 -- plsql record structure we call the corresponding record business process.
346 --
347 hr_fim_ins.ins
348 (p_effective_date
349 ,l_rec
350 );
351 --
352 -- As the primary key argument(s)
353 -- are specified as an OUT's we must set these values.
354 --
355 p_form_item_id := l_rec.form_item_id;
356 p_object_version_number := l_rec.object_version_number;
357 --
358 hr_utility.set_location(' Leaving:'||l_proc, 10);
359 End ins;
360 --
361 end hr_fim_ins;