1 Package Body ghr_pdc_ins as
2 /* $Header: ghpdcrhi.pkb 120.0.12010000.3 2009/05/27 05:40:10 utokachi noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := 'ghr_pdc_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 structure.
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(p_rec in out NOCOPY ghr_pdc_shd.g_rec_type) is
54 --
55 l_proc varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58 hr_utility.set_location('Entering:'||l_proc, 5);
59 p_rec.object_version_number := 1; -- Initialise the object version
60 --
61 --ghr_pdc_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: ghr_pd_classifications
64 --
65 insert into ghr_pd_classifications
66 ( pd_classification_id,
67 position_description_id,
68 class_grade_by,
69 official_title,
70 pay_plan,
71 occupational_code,
72 grade_level,
73 object_version_number
74 )
75 Values
76 ( p_rec.pd_classification_id,
77 p_rec.position_description_id,
78 p_rec.class_grade_by,
79 p_rec.official_title,
80 p_rec.pay_plan,
81 p_rec.occupational_code,
82 p_rec.grade_level,
83 p_rec.object_version_number
84 );
85 --
86 --ghr_pdc_shd.g_api_dml := false; -- Unset the api dml status
87 --
88 hr_utility.set_location(' Leaving:'||l_proc, 10);
89 Exception
90 When hr_api.check_integrity_violated Then
91 -- A check constraint has been violated
92 --ghr_pdc_shd.g_api_dml := false; -- Unset the api dml status
93 ghr_pdc_shd.constraint_error
94 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95 When hr_api.parent_integrity_violated Then
96 -- Parent integrity has been violated
97 --ghr_pdc_shd.g_api_dml := false; -- Unset the api dml status
98 ghr_pdc_shd.constraint_error
99 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100 When hr_api.unique_integrity_violated Then
101 -- Unique integrity has been violated
102 --ghr_pdc_shd.g_api_dml := false; -- Unset the api dml status
103 ghr_pdc_shd.constraint_error
104 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105 When Others Then
106 --ghr_pdc_shd.g_api_dml := false; -- Unset the api dml status
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 structure.
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 ghr_pdc_shd.g_rec_type) is
148 --
149 l_proc varchar2(72) := g_package||'pre_insert';
150 --
151 Cursor C_Sel1 is select ghr_pd_classifications_s.nextval from sys.dual;
152 --
153 Begin
154 hr_utility.set_location('Entering:'||l_proc, 5);
155 --
156 --
157 -- Select the next sequence number
158 --
159 Open C_Sel1;
160 Fetch C_Sel1 Into p_rec.pd_classification_id;
161 Close C_Sel1;
162 --
163 hr_utility.set_location(' Leaving:'||l_proc, 10);
164 End pre_insert;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |-----------------------------< post_insert >------------------------------|
168 -- ----------------------------------------------------------------------------
169 -- {Start Of Comments}
170 --
171 -- Description:
172 -- This private procedure contains any processing which is required after the
173 -- insert dml.
174 --
175 -- Prerequisites:
176 -- This is an internal procedure which is called from the ins procedure.
177 --
178 -- In Parameters:
179 -- A Pl/Sql record structure.
180 --
181 -- Post Success:
182 -- Processing continues.
183 --
184 -- Post Failure:
185 -- If an error has occurred, an error message and exception will be raised
186 -- but not handled.
187 --
188 -- Developer Implementation Notes:
189 -- Any post-processing required after the insert dml is issued should be
190 -- coded within this procedure. It is important to note that any 3rd party
191 -- maintenance should be reviewed before placing in this procedure.
192 --
193 -- Access Status:
194 -- Internal Row Handler Use Only.
195 --
196 -- {End Of Comments}
197 -- ----------------------------------------------------------------------------
198 Procedure post_insert(p_rec in ghr_pdc_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 -- This is a hook point and the user hook for post_insert is called here.
207 --
208 begin
209 ghr_pdc_rki.after_insert (
210 p_pd_classification_id => p_rec.pd_classification_id,
211 p_position_description_id => p_rec.position_description_id,
212 p_class_grade_by => p_rec.class_grade_by,
213 p_official_title => p_rec.official_title,
214 p_pay_plan => p_rec.pay_plan,
215 p_occupational_code => p_rec.occupational_code,
216 p_grade_level => p_rec.grade_level,
217 p_object_version_number => p_rec.object_version_number
218 );
219 exception
220 when hr_api.cannot_find_prog_unit then
221 hr_api.cannot_find_prog_unit_error
222 ( p_module_name => 'GHR_PD_CLASSIFICATIONS'
223 ,p_hook_type => 'AI'
224 );
225 end;
226 -- End of API User Hook for post_insert.
227 --
228 hr_utility.set_location(' Leaving:'||l_proc, 10);
229 End post_insert;
230 --
231 -- ----------------------------------------------------------------------------
232 -- |---------------------------------< ins >----------------------------------|
233 -- ----------------------------------------------------------------------------
234 Procedure ins
235 (
236 p_rec in out NOCOPY ghr_pdc_shd.g_rec_type
237 ) is
238 --
239 l_proc varchar2(72) := g_package||'ins';
240 --
241 Begin
242 hr_utility.set_location('Entering:'||l_proc, 5);
243 --
244 -- Call the supporting insert validate operations
245 --
246 ghr_pdc_bus.insert_validate(p_rec);
247 --
248 -- Call the supporting pre-insert operation
249 --
250 pre_insert(p_rec);
251 --
252 -- Insert the row
253 --
254 insert_dml(p_rec);
255 --
256 -- Call the supporting post-insert operation
257 --
258 post_insert(p_rec);
259 end ins;
260 --
261 -- ----------------------------------------------------------------------------
262 -- |---------------------------------< ins >----------------------------------|
263 -- ----------------------------------------------------------------------------
264 Procedure ins
265 (
266 p_pd_classification_id out NOCOPY number,
267 p_position_description_id in number,
268 p_class_grade_by in varchar2,
269 p_official_title in varchar2 default null,
270 p_pay_plan in varchar2 default null,
271 p_occupational_code in varchar2 default null,
272 p_grade_level in varchar2 default null,
273 p_object_version_number out NOCOPY number
274 ) is
275 --
276 l_rec ghr_pdc_shd.g_rec_type;
277 l_proc varchar2(72) := g_package||'ins';
278 --
279 Begin
280 hr_utility.set_location('Entering:'||l_proc, 5);
281 --
282 -- Call conversion function to turn arguments into the
283 -- p_rec structure.
284 --
285 -- Class Grade by
286 hr_api.mandatory_arg_error
287 (p_api_name => l_proc,
288 p_argument => 'Class Grade By',
289 p_argument_value => p_class_grade_by
290 );
291 -- Official Title
292 hr_api.mandatory_arg_error
293 (p_api_name => l_proc,
294 p_argument => 'Position Title',
295 p_argument_value => p_official_title
296 );
297 -- Pay plan
298 hr_api.mandatory_arg_error
299 (p_api_name => l_proc,
300 p_argument => 'Pay Plan',
301 p_argument_value => p_pay_plan
302 );
303 -- Occ Code
304 hr_api.mandatory_arg_error
305 (p_api_name => l_proc,
306 p_argument => 'Occupational Series',
307 p_argument_value => p_occupational_code
308 );
309 -- Grade or Level
310 hr_api.mandatory_arg_error
311 (p_api_name => l_proc,
312 p_argument => 'Grade',
313 p_argument_value => p_grade_level
314 );
315 l_rec :=
316 ghr_pdc_shd.convert_args
317 (
318 null,
319 p_position_description_id,
320 p_class_grade_by,
321 p_official_title,
322 p_pay_plan,
323 p_occupational_code,
324 p_grade_level,
325 null
326 );
327 --
328 -- Having converted the arguments into the ghr_pdc_rec
329 -- plsql record structure we call the corresponding record business process.
330 --
331 ins(l_rec);
332 --
333 -- As the primary key argument(s)
334 -- are specified as an OUT's we must set these values.
335 --
336 p_pd_classification_id := l_rec.pd_classification_id;
337 p_object_version_number := l_rec.object_version_number;
338 --
339 hr_utility.set_location(' Leaving:'||l_proc, 10);
340 End ins;
341 --
342 end ghr_pdc_ins;