1 Package Body pqh_rst_ins as
2 /* $Header: pqrstrhi.pkb 120.5 2011/04/28 09:38:46 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_rst_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 insert the row into the schema.
21 -- 4) To trap any constraint violations that may have occurred.
22 -- 5) To raise any other errors.
23 --
24 -- Prerequisites:
25 -- This is an internal private procedure which must be called from the ins
26 -- procedure and must have all mandatory attributes set (except the
27 -- object_version_number which is initialised within this procedure).
28 --
29 -- In Parameters:
30 -- A Pl/Sql record structre.
31 --
32 -- Post Success:
33 -- The specified row will be inserted into the schema.
34 --
35 -- Post Failure:
36 -- If a check, unique or parent integrity constraint violation is raised the
37 -- constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 -- None.
41 --
42 -- Access Status:
43 -- Internal Row Handler Use Only.
44 --
45 -- {End Of Comments}
46 -- ----------------------------------------------------------------------------
47 Procedure insert_dml(p_rec in out nocopy pqh_rst_shd.g_rec_type) is
48 --
49 l_proc varchar2(72) := g_package||'insert_dml';
50 --
51 Begin
52 hr_utility.set_location('Entering:'||l_proc, 5);
53 p_rec.object_version_number := 1; -- Initialise the object version
54 --
55 --
56 -- Added the following code as a part of Zero Downtime Patching Project.
57 -- Code Starts Here.
58 --
59 PER_RIC_PKG.chk_integrity (
60 p_entity_name=>'PQH_RULE_SETS',
61 p_ref_entity_info=>
62 PER_RIC_PKG.ref_entity_tbl(
63 PER_RIC_PKG.ref_info_rec('HR_ALL_ORGANIZATION_UNITS',PER_RIC_PKG.column_info_tbl(
64 PER_RIC_PKG.col_info_rec('ORGANIZATION_ID',NULL,p_rec.organization_id, NULL))),
65 PER_RIC_PKG.ref_info_rec('HR_ALL_ORGANIZATION_UNITS',PER_RIC_PKG.column_info_tbl(
66 PER_RIC_PKG.col_info_rec('BUSINESS_GROUP_ID',NULL,p_rec.business_group_id, NULL))),
67 PER_RIC_PKG.ref_info_rec('PER_ORGANIZATION_STRUCTURES',PER_RIC_PKG.column_info_tbl(
68 PER_RIC_PKG.col_info_rec('ORGANIZATION_STRUCTURE_ID',NULL,p_rec.organization_structure_id, NULL)))),
69 p_ref_type=>'INS');
70 --
71 -- Code Ends Here
72 --
73 --
74 -- Insert the row into: pqh_rule_sets
75 --
76 insert into pqh_rule_sets
77 ( business_group_id,
78 rule_set_id,
79 rule_set_name,
80 organization_structure_id,
81 organization_id,
82 referenced_rule_set_id,
83 rule_level_cd,
84 object_version_number,
85 short_name,
86 rule_applicability,
87 rule_category,
88 starting_organization_id,
89 seeded_rule_flag,
90 status
91 )
92 Values
93 ( p_rec.business_group_id,
94 p_rec.rule_set_id,
95 p_rec.rule_set_name,
96 p_rec.organization_structure_id,
97 p_rec.organization_id,
98 p_rec.referenced_rule_set_id,
99 p_rec.rule_level_cd,
100 p_rec.object_version_number,
101 p_rec.short_name,
102 p_rec.rule_applicability,
103 p_rec.rule_category,
104 p_rec.starting_organization_id,
105 p_rec.seeded_rule_flag,
106 p_rec.status
107 );
108 --
109 --
110 hr_utility.set_location(' Leaving:'||l_proc, 10);
111 Exception
112 When hr_api.check_integrity_violated Then
113 -- A check constraint has been violated
114 pqh_rst_shd.constraint_error
115 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
116 When hr_api.parent_integrity_violated Then
117 -- Parent integrity has been violated
118 pqh_rst_shd.constraint_error
119 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120 When hr_api.unique_integrity_violated Then
121 -- Unique integrity has been violated
122 pqh_rst_shd.constraint_error
123 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
124 When Others Then
125 Raise;
126 End insert_dml;
127 --
128 -- ----------------------------------------------------------------------------
129 -- |------------------------------< pre_insert >------------------------------|
130 -- ----------------------------------------------------------------------------
131 -- {Start Of Comments}
132 --
133 -- Description:
134 -- This private procedure contains any processing which is required before
135 -- the insert dml. Presently, if the entity has a corresponding primary
136 -- key which is maintained by an associating sequence, the primary key for
137 -- the entity will be populated with the next sequence value in
138 -- preparation for the insert dml.
139 --
140 -- Prerequisites:
141 -- This is an internal procedure which is called from the ins procedure.
142 --
143 -- In Parameters:
144 -- A Pl/Sql record structre.
145 --
146 -- Post Success:
147 -- Processing continues.
148 --
149 -- Post Failure:
150 -- If an error has occurred, an error message and exception will be raised
151 -- but not handled.
152 --
153 -- Developer Implementation Notes:
154 -- Any pre-processing required before the insert dml is issued should be
155 -- coded within this procedure. As stated above, a good example is the
156 -- generation of a primary key number via a corresponding sequence.
157 -- It is important to note that any 3rd party maintenance should be reviewed
158 -- before placing in this procedure.
159 --
160 -- Access Status:
161 -- Internal Row Handler Use Only.
162 --
163 -- {End Of Comments}
164 -- ----------------------------------------------------------------------------
165 Procedure pre_insert(p_rec in out nocopy pqh_rst_shd.g_rec_type) is
166 --
167 l_proc varchar2(72) := g_package||'pre_insert';
168 --
169 --
170 Cursor C_Sel1 is select pqh_rule_sets_s.nextval from sys.dual;
171 --
172 --
173 Begin
174 hr_utility.set_location('Entering:'||l_proc, 5);
175 --
176 open C_Sel1;
177 fetch C_Sel1 into p_rec.rule_set_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_effective_date in date,p_rec in pqh_rst_shd.g_rec_type) is
217 --
218 l_proc varchar2(72) := g_package||'post_insert';
219 --
220 Begin
221 hr_utility.set_location('Entering:'||l_proc, 5);
222 --
223 --
224 -- Start of API User Hook for post_insert.
225 --
226 begin
227 --
228 pqh_rst_rki.after_insert
229 (
230 p_business_group_id =>p_rec.business_group_id
231 ,p_rule_set_id =>p_rec.rule_set_id
232 ,p_rule_set_name =>p_rec.rule_set_name
233 ,p_organization_structure_id =>p_rec.organization_structure_id
234 ,p_organization_id =>p_rec.organization_id
235 ,p_referenced_rule_set_id =>p_rec.referenced_rule_set_id
236 ,p_rule_level_cd =>p_rec.rule_level_cd
237 ,p_object_version_number =>p_rec.object_version_number
238 ,p_short_name =>p_rec.short_name
239 ,p_rule_applicability =>p_rec.rule_applicability
240 ,p_rule_category =>p_rec.rule_category
241 ,p_starting_organization_id =>p_rec.starting_organization_id
242 ,p_seeded_rule_flag =>p_rec.seeded_rule_flag
243 ,p_status =>p_rec.status
244 ,p_effective_date =>p_effective_date
245 );
246 --
247 exception
248 --
249 when hr_api.cannot_find_prog_unit then
250 --
251 hr_api.cannot_find_prog_unit_error
252 (p_module_name => 'pqh_rule_sets'
253 ,p_hook_type => 'AI');
254 --
255 end;
256 --
257 -- End of API User Hook for post_insert.
258 --
259 --
260 hr_utility.set_location(' Leaving:'||l_proc, 10);
261 End post_insert;
262 --
263 -- ----------------------------------------------------------------------------
264 -- |---------------------------------< ins >----------------------------------|
265 -- ----------------------------------------------------------------------------
266 Procedure ins
267 (
268 p_effective_date in date,
269 p_rec in out nocopy pqh_rst_shd.g_rec_type
270 ) is
271 --
272 l_proc varchar2(72) := g_package||'ins';
273 --
274 Begin
275 hr_utility.set_location('Entering:'||l_proc, 5);
276 --
277 -- Call the supporting insert validate operations
278 --
279 pqh_rst_bus.insert_validate(p_rec
280 ,p_effective_date);
281 --
282 -- Call the supporting pre-insert operation
283 --
284 pre_insert(p_rec);
285 --
286 -- Insert the row
287 --
288 insert_dml(p_rec);
289 --
290 -- Call the supporting post-insert operation
291 --
292 post_insert(
293 p_effective_date,p_rec);
294 end ins;
295 --
296 -- ----------------------------------------------------------------------------
297 -- |---------------------------------< ins >----------------------------------|
298 -- ----------------------------------------------------------------------------
299 Procedure ins
300 (
301 p_effective_date in date,
302 p_business_group_id in number,
303 p_rule_set_id out nocopy number,
304 p_rule_set_name in varchar2 default null,
305 p_organization_structure_id in number default null,
306 p_organization_id in number default null,
307 p_referenced_rule_set_id in number default null,
308 p_rule_level_cd in varchar2,
309 p_object_version_number out nocopy number,
310 p_short_name in varchar2,
311 p_rule_applicability in varchar2 default 'NONE',
312 p_rule_category in varchar2,
313 p_starting_organization_id in number default null,
314 p_seeded_rule_flag in varchar2 default 'N',
315 p_status in varchar2 default null
316 ) is
317 --
318 l_rec pqh_rst_shd.g_rec_type;
319 l_proc varchar2(72) := g_package||'ins';
320 --
321 Begin
322 hr_utility.set_location('Entering:'||l_proc, 5);
323 --
324 -- Call conversion function to turn arguments into the
325 -- p_rec structure.
326 --
327 l_rec :=
328 pqh_rst_shd.convert_args
329 (
330 p_business_group_id,
331 null,
332 p_rule_set_name,
333 p_organization_structure_id,
334 p_organization_id,
335 p_referenced_rule_set_id,
336 p_rule_level_cd,
337 null,
338 p_short_name,
339 p_rule_applicability,
340 p_rule_category,
341 p_starting_organization_id,
342 p_seeded_rule_flag,
343 p_status
344 );
345 --
346 -- Having converted the arguments into the pqh_rst_rec
347 -- plsql record structure we call the corresponding record business process.
348 --
349 ins(
350 p_effective_date,l_rec);
351 --
352 -- As the primary key argument(s)
353 -- are specified as an OUT's we must set these values.
354 --
355 p_rule_set_id := l_rec.rule_set_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 pqh_rst_ins;