1 Package Body pqh_rst_ins as
2 /* $Header: pqrstrhi.pkb 120.2.12000000.2 2007/04/19 12:46:34 brsinha noship $ */
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 -- Insert the row into: pqh_rule_sets
57 --
58 insert into pqh_rule_sets
59 ( business_group_id,
60 rule_set_id,
61 rule_set_name,
62 organization_structure_id,
63 organization_id,
64 referenced_rule_set_id,
65 rule_level_cd,
66 object_version_number,
67 short_name,
68 rule_applicability,
69 rule_category,
70 starting_organization_id,
71 seeded_rule_flag,
72 status
73 )
74 Values
75 ( p_rec.business_group_id,
76 p_rec.rule_set_id,
77 p_rec.rule_set_name,
78 p_rec.organization_structure_id,
79 p_rec.organization_id,
80 p_rec.referenced_rule_set_id,
81 p_rec.rule_level_cd,
82 p_rec.object_version_number,
83 p_rec.short_name,
84 p_rec.rule_applicability,
85 p_rec.rule_category,
86 p_rec.starting_organization_id,
87 p_rec.seeded_rule_flag,
88 p_rec.status
89 );
90 --
91 --
92 hr_utility.set_location(' Leaving:'||l_proc, 10);
93 Exception
94 When hr_api.check_integrity_violated Then
95 -- A check constraint has been violated
96 pqh_rst_shd.constraint_error
97 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98 When hr_api.parent_integrity_violated Then
99 -- Parent integrity has been violated
100 pqh_rst_shd.constraint_error
101 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102 When hr_api.unique_integrity_violated Then
103 -- Unique integrity has been violated
104 pqh_rst_shd.constraint_error
105 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106 When Others Then
107 Raise;
108 End insert_dml;
109 --
110 -- ----------------------------------------------------------------------------
111 -- |------------------------------< pre_insert >------------------------------|
112 -- ----------------------------------------------------------------------------
113 -- {Start Of Comments}
114 --
115 -- Description:
116 -- This private procedure contains any processing which is required before
117 -- the insert dml. Presently, if the entity has a corresponding primary
118 -- key which is maintained by an associating sequence, the primary key for
119 -- the entity will be populated with the next sequence value in
120 -- preparation for the insert dml.
121 --
122 -- Prerequisites:
123 -- This is an internal procedure which is called from the ins procedure.
124 --
125 -- In Parameters:
126 -- A Pl/Sql record structre.
127 --
128 -- Post Success:
129 -- Processing continues.
130 --
131 -- Post Failure:
132 -- If an error has occurred, an error message and exception will be raised
133 -- but not handled.
134 --
135 -- Developer Implementation Notes:
136 -- Any pre-processing required before the insert dml is issued should be
137 -- coded within this procedure. As stated above, a good example is the
138 -- generation of a primary key number via a corresponding sequence.
139 -- It is important to note that any 3rd party maintenance should be reviewed
140 -- before placing in this procedure.
141 --
142 -- Access Status:
143 -- Internal Row Handler Use Only.
144 --
145 -- {End Of Comments}
146 -- ----------------------------------------------------------------------------
147 Procedure pre_insert(p_rec in out nocopy pqh_rst_shd.g_rec_type) is
148 --
149 l_proc varchar2(72) := g_package||'pre_insert';
150 --
151 --
152 Cursor C_Sel1 is select pqh_rule_sets_s.nextval from sys.dual;
153 --
154 --
155 Begin
156 hr_utility.set_location('Entering:'||l_proc, 5);
157 --
158 open C_Sel1;
159 fetch C_Sel1 into p_rec.rule_set_id ;
160 close C_Sel1;
161 --
162 hr_utility.set_location(' Leaving:'||l_proc, 10);
163 End pre_insert;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |-----------------------------< post_insert >------------------------------|
167 -- ----------------------------------------------------------------------------
168 -- {Start Of Comments}
169 --
170 -- Description:
171 -- This private procedure contains any processing which is required after the
172 -- insert dml.
173 --
174 -- Prerequisites:
175 -- This is an internal procedure which is called from the ins procedure.
176 --
177 -- In Parameters:
178 -- A Pl/Sql record structre.
179 --
180 -- Post Success:
181 -- Processing continues.
182 --
183 -- Post Failure:
184 -- If an error has occurred, an error message and exception will be raised
185 -- but not handled.
186 --
187 -- Developer Implementation Notes:
188 -- Any post-processing required after the insert dml is issued should be
189 -- coded within this procedure. It is important to note that any 3rd party
190 -- maintenance should be reviewed before placing in this procedure.
191 --
192 -- Access Status:
193 -- Internal Row Handler Use Only.
194 --
195 -- {End Of Comments}
196 -- ----------------------------------------------------------------------------
197 Procedure post_insert(
198 p_effective_date in date,p_rec in pqh_rst_shd.g_rec_type) is
199 --
200 l_proc varchar2(72) := g_package||'post_insert';
201 --
202 Begin
203 hr_utility.set_location('Entering:'||l_proc, 5);
204 --
205 --
206 -- Start of API User Hook for post_insert.
207 --
208 begin
209 --
210 pqh_rst_rki.after_insert
211 (
212 p_business_group_id =>p_rec.business_group_id
213 ,p_rule_set_id =>p_rec.rule_set_id
214 ,p_rule_set_name =>p_rec.rule_set_name
215 ,p_organization_structure_id =>p_rec.organization_structure_id
216 ,p_organization_id =>p_rec.organization_id
217 ,p_referenced_rule_set_id =>p_rec.referenced_rule_set_id
218 ,p_rule_level_cd =>p_rec.rule_level_cd
219 ,p_object_version_number =>p_rec.object_version_number
220 ,p_short_name =>p_rec.short_name
221 ,p_rule_applicability =>p_rec.rule_applicability
222 ,p_rule_category =>p_rec.rule_category
223 ,p_starting_organization_id =>p_rec.starting_organization_id
224 ,p_seeded_rule_flag =>p_rec.seeded_rule_flag
225 ,p_status =>p_rec.status
226 ,p_effective_date =>p_effective_date
227 );
228 --
229 exception
230 --
231 when hr_api.cannot_find_prog_unit then
232 --
233 hr_api.cannot_find_prog_unit_error
234 (p_module_name => 'pqh_rule_sets'
235 ,p_hook_type => 'AI');
236 --
237 end;
238 --
239 -- End of API User Hook for post_insert.
240 --
241 --
242 hr_utility.set_location(' Leaving:'||l_proc, 10);
243 End post_insert;
244 --
245 -- ----------------------------------------------------------------------------
246 -- |---------------------------------< ins >----------------------------------|
247 -- ----------------------------------------------------------------------------
248 Procedure ins
249 (
250 p_effective_date in date,
251 p_rec in out nocopy pqh_rst_shd.g_rec_type
252 ) is
253 --
254 l_proc varchar2(72) := g_package||'ins';
255 --
256 Begin
257 hr_utility.set_location('Entering:'||l_proc, 5);
258 --
259 -- Call the supporting insert validate operations
260 --
261 pqh_rst_bus.insert_validate(p_rec
262 ,p_effective_date);
263 --
264 -- Call the supporting pre-insert operation
265 --
266 pre_insert(p_rec);
267 --
268 -- Insert the row
269 --
270 insert_dml(p_rec);
271 --
272 -- Call the supporting post-insert operation
273 --
274 post_insert(
275 p_effective_date,p_rec);
276 end ins;
277 --
278 -- ----------------------------------------------------------------------------
279 -- |---------------------------------< ins >----------------------------------|
280 -- ----------------------------------------------------------------------------
281 Procedure ins
282 (
283 p_effective_date in date,
284 p_business_group_id in number,
285 p_rule_set_id out nocopy number,
286 p_rule_set_name in varchar2 default null,
287 p_organization_structure_id in number default null,
288 p_organization_id in number default null,
289 p_referenced_rule_set_id in number default null,
290 p_rule_level_cd in varchar2,
291 p_object_version_number out nocopy number,
292 p_short_name in varchar2,
293 p_rule_applicability in varchar2 default 'NONE',
294 p_rule_category in varchar2,
295 p_starting_organization_id in number default null,
296 p_seeded_rule_flag in varchar2 default 'N',
297 p_status in varchar2 default null
298 ) is
299 --
300 l_rec pqh_rst_shd.g_rec_type;
301 l_proc varchar2(72) := g_package||'ins';
302 --
303 Begin
304 hr_utility.set_location('Entering:'||l_proc, 5);
305 --
306 -- Call conversion function to turn arguments into the
307 -- p_rec structure.
308 --
309 l_rec :=
310 pqh_rst_shd.convert_args
311 (
312 p_business_group_id,
313 null,
314 p_rule_set_name,
315 p_organization_structure_id,
316 p_organization_id,
317 p_referenced_rule_set_id,
318 p_rule_level_cd,
319 null,
320 p_short_name,
321 p_rule_applicability,
322 p_rule_category,
323 p_starting_organization_id,
324 p_seeded_rule_flag,
325 p_status
326 );
327 --
328 -- Having converted the arguments into the pqh_rst_rec
329 -- plsql record structure we call the corresponding record business process.
330 --
331 ins(
332 p_effective_date,l_rec);
333 --
334 -- As the primary key argument(s)
335 -- are specified as an OUT's we must set these values.
336 --
337 p_rule_set_id := l_rec.rule_set_id;
338 p_object_version_number := l_rec.object_version_number;
339 --
340 hr_utility.set_location(' Leaving:'||l_proc, 10);
341 End ins;
342 --
343 end pqh_rst_ins;