1 Package Body ghr_pre_ins as
2 /* $Header: ghprerhi.pkb 115.3 1999/11/09 22:46:04 pkm ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_pre_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 -- 3) To trap any constraint violations that may have occurred.
22 -- 4) To raise any other errors.
23 --
24 -- Pre Conditions:
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 Table Handler Use Only.
44 --
45 -- {End Of Comments}
46 -- ----------------------------------------------------------------------------
47 Procedure insert_dml(p_rec in out ghr_pre_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 -- Insert the row into: ghr_pa_remarks
56 --
57 insert into ghr_pa_remarks
58 ( pa_remark_id,
59 pa_request_id,
60 remark_id,
61 description,
62 remark_code_information1,
63 remark_code_information2,
64 remark_code_information3,
65 remark_code_information4,
66 remark_code_information5,
67 object_version_number
68 )
69 Values
70 ( p_rec.pa_remark_id,
71 p_rec.pa_request_id,
72 p_rec.remark_id,
73 p_rec.description,
74 p_rec.remark_code_information1,
75 p_rec.remark_code_information2,
76 p_rec.remark_code_information3,
77 p_rec.remark_code_information4,
78 p_rec.remark_code_information5,
79 p_rec.object_version_number
80 );
81 --
82
83 hr_utility.set_location(' Leaving:'||l_proc, 10);
84 Exception
85 When hr_api.check_integrity_violated Then
86 -- A check constraint has been violated
87 ghr_pre_shd.constraint_error
88 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
89 When hr_api.parent_integrity_violated Then
90 -- Parent integrity has been violated
91 ghr_pre_shd.constraint_error
92 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93 When hr_api.unique_integrity_violated Then
94 -- Unique integrity has been violated
95 ghr_pre_shd.constraint_error
96 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97 When Others Then
98 Raise;
99 End insert_dml;
100 --
101 -- ----------------------------------------------------------------------------
102 -- |------------------------------< pre_insert >------------------------------|
103 -- ----------------------------------------------------------------------------
104 -- {Start Of Comments}
105 --
106 -- Description:
107 -- This private procedure contains any processing which is required before
108 -- the insert dml. Presently, if the entity has a corresponding primary
109 -- key which is maintained by an associating sequence, the primary key for
110 -- the entity will be populated with the next sequence value in
111 -- preparation for the insert dml.
112 --
113 -- Pre Conditions:
114 -- This is an internal procedure which is called from the ins procedure.
115 --
116 -- In Parameters:
117 -- A Pl/Sql record structre.
118 --
119 -- Post Success:
120 -- Processing continues.
121 --
122 -- Post Failure:
123 -- If an error has occurred, an error message and exception will be raised
124 -- but not handled.
125 --
126 -- Developer Implementation Notes:
127 -- Any pre-processing required before the insert dml is issued should be
128 -- coded within this procedure. As stated above, a good example is the
129 -- generation of a primary key number via a corresponding sequence.
130 -- It is important to note that any 3rd party maintenance should be reviewed
131 -- before placing in this procedure.
132 --
133 -- Access Status:
134 -- Internal Table Handler Use Only.
135 --
136 -- {End Of Comments}
137 -- ----------------------------------------------------------------------------
138 Procedure pre_insert(p_rec in out ghr_pre_shd.g_rec_type) is
139 --
140 l_proc varchar2(72) := g_package||'pre_insert';
141 --
142 Cursor C_Sel1 is select ghr_pa_remarks_s.nextval from sys.dual;
143 --
144 Begin
145 hr_utility.set_location('Entering:'||l_proc, 5);
146 --
147 --
148 -- Select the next sequence number
149 --
150 Open C_Sel1;
151 Fetch C_Sel1 Into p_rec.pa_remark_id;
152 Close C_Sel1;
153 --
154 hr_utility.set_location(' Leaving:'||l_proc, 10);
155 End pre_insert;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |-----------------------------< post_insert >------------------------------|
159 -- ----------------------------------------------------------------------------
160 -- {Start Of Comments}
161 --
162 -- Description:
163 -- This private procedure contains any processing which is required after the
164 -- insert dml.
165 --
166 -- Pre Conditions:
167 -- This is an internal procedure which is called from the ins procedure.
168 --
169 -- In Parameters:
170 -- A Pl/Sql record structre.
171 --
172 -- Post Success:
173 -- Processing continues.
174 --
175 -- Post Failure:
176 -- If an error has occurred, an error message and exception will be raised
177 -- but not handled.
178 --
179 -- Developer Implementation Notes:
180 -- Any post-processing required after the insert dml is issued should be
181 -- coded within this procedure. It is important to note that any 3rd party
182 -- maintenance should be reviewed before placing in this procedure.
183 --
184 -- Access Status:
185 -- Internal Table Handler Use Only.
186 --
187 -- {End Of Comments}
188 -- ----------------------------------------------------------------------------
189 Procedure post_insert(p_rec in ghr_pre_shd.g_rec_type) is
190 --
191 l_proc varchar2(72) := g_package||'post_insert';
192 --
193 Begin
194 hr_utility.set_location('Entering:'||l_proc, 5);
195 --
196 -- This is a hook point and the user hook for post_insert is called here.
197 --
198 begin
199 ghr_pre_rki.after_insert (
200 p_pa_remark_id => p_rec.pa_remark_id,
201 p_pa_request_id => p_rec.pa_request_id,
202 p_remark_id => p_rec.remark_id,
203 p_description => p_rec.description,
204 p_remark_code_information1 => p_rec.remark_code_information1,
205 p_remark_code_information2 => p_rec.remark_code_information2,
206 p_remark_code_information3 => p_rec.remark_code_information3,
207 p_remark_code_information4 => p_rec.remark_code_information4,
208 p_remark_code_information5 => p_rec.remark_code_information5,
209 p_object_version_number => p_rec.object_version_number);
210
211 exception
212 when hr_api.cannot_find_prog_unit then
213 hr_api.cannot_find_prog_unit_error
214 ( p_module_name => 'GHR_PA_REMARKS'
215 ,p_hook_type => 'AI'
216 );
217 end;
218 -- End of API User Hook for post_insert.
219 --
220 hr_utility.set_location(' Leaving:'||l_proc, 10);
221 End post_insert;
222 --
223 -- ----------------------------------------------------------------------------
224 -- |---------------------------------< ins >----------------------------------|
225 -- ----------------------------------------------------------------------------
226 Procedure ins
227 (
228 p_rec in out ghr_pre_shd.g_rec_type,
229 p_validate in boolean default false
230 ) is
231 --
232 l_proc varchar2(72) := g_package||'ins';
233 --
234 Begin
235 hr_utility.set_location('Entering:'||l_proc, 5);
236 --
237 -- Determine if the business process is to be validated.
238 --
239 If p_validate then
240 --
241 -- Issue the savepoint.
242 --
243 SAVEPOINT ins_ghr_pre;
244 End If;
245 --
246 -- Call the supporting insert validate operations
247 --
248 ghr_pre_bus.insert_validate(p_rec);
249 --
250 -- Call the supporting pre-insert operation
251 --
252 pre_insert(p_rec);
253 --
254 -- Insert the row
255 --
256 insert_dml(p_rec);
257 --
258 -- Call the supporting post-insert operation
259 --
260 post_insert(p_rec);
261 --
262 -- If we are validating then raise the Validate_Enabled exception
263 --
264 If p_validate then
265 Raise HR_Api.Validate_Enabled;
266 End If;
267 --
268 hr_utility.set_location(' Leaving:'||l_proc, 10);
269 Exception
270 When HR_Api.Validate_Enabled Then
271 --
272 -- As the Validate_Enabled exception has been raised
273 -- we must rollback to the savepoint
274 --
275 ROLLBACK TO ins_ghr_pre;
276 end ins;
277 --
278 -- ----------------------------------------------------------------------------
279 -- |---------------------------------< ins >----------------------------------|
280 -- ----------------------------------------------------------------------------
281 Procedure ins
282 (
283 p_pa_remark_id out number,
284 p_pa_request_id in number,
285 p_remark_id in number,
286 p_description in varchar2 default null,
287 p_remark_code_information1 in varchar2 default null,
288 p_remark_code_information2 in varchar2 default null,
289 p_remark_code_information3 in varchar2 default null,
290 p_remark_code_information4 in varchar2 default null,
291 p_remark_code_information5 in varchar2 default null,
292 p_object_version_number out number,
293 p_validate in boolean default false
294 ) is
295 --
296
297 l_rec ghr_pre_shd.g_rec_type;
298 l_proc varchar2(72) := g_package||'ins';
299 --
300 Begin
301 hr_utility.set_location('Entering:'||l_proc, 5);
302 --
303 -- Call conversion function to turn arguments into the
304 -- p_rec structure.
305 --
306 l_rec :=
307 ghr_pre_shd.convert_args
308 (
309 null,
310 p_pa_request_id,
311 p_remark_id,
312 p_description,
313 p_remark_code_information1,
314 p_remark_code_information2,
315 p_remark_code_information3,
316 p_remark_code_information4,
317 p_remark_code_information5,
318 null
319 );
320 --
321 -- Having converted the arguments into the ghr_pre_rec
322 -- plsql record structure we call the corresponding record business process.
323 --
324 ins(l_rec, p_validate);
325 --
326 -- As the primary key argument(s)
327 -- are specified as an OUT's we must set these values.
328 --
329 p_pa_remark_id := l_rec.pa_remark_id;
330 p_object_version_number := l_rec.object_version_number;
331 --
332 hr_utility.set_location(' Leaving:'||l_proc, 10);
333 End ins;
334 --
335 end ghr_pre_ins;