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