1 Package Body ssp_stp_ins as
2 /* $Header: spstprhi.pkb 115.3 99/10/13 01:54:40 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ssp_stp_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 -- Pre Conditions:
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 Table Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out ssp_stp_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 ssp_stp_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: ssp_stoppages
64 --
65 insert into ssp_stoppages
66 ( stoppage_id,
67 object_version_number,
68 absence_attendance_id,
69 maternity_id,
70 reason_id,
71 user_entered,
72 override_stoppage,
73 employee_notified,
74 withhold_from,
75 withhold_to
76 )
77 Values
78 ( p_rec.stoppage_id,
79 p_rec.object_version_number,
80 p_rec.absence_attendance_id,
81 p_rec.maternity_id,
82 p_rec.reason_id,
83 p_rec.user_entered,
84 p_rec.override_stoppage,
85 p_rec.employee_notified,
86 p_rec.withhold_from,
87 p_rec.withhold_to
88 );
89 --
90 ssp_stp_shd.g_api_dml := false; -- Unset the api dml status
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 ssp_stp_shd.g_api_dml := false; -- Unset the api dml status
97 ssp_stp_shd.constraint_error
98 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99 When hr_api.parent_integrity_violated Then
100 -- Parent integrity has been violated
101 ssp_stp_shd.g_api_dml := false; -- Unset the api dml status
102 ssp_stp_shd.constraint_error
103 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104 When hr_api.unique_integrity_violated Then
105 -- Unique integrity has been violated
106 ssp_stp_shd.g_api_dml := false; -- Unset the api dml status
107 ssp_stp_shd.constraint_error
108 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109 When Others Then
110 ssp_stp_shd.g_api_dml := false; -- Unset the api dml status
111 Raise;
112 End insert_dml;
113 --
114 -- ----------------------------------------------------------------------------
115 -- |------------------------------< pre_insert >------------------------------|
116 -- ----------------------------------------------------------------------------
117 -- {Start Of Comments}
118 --
119 -- Description:
120 -- This private procedure contains any processing which is required before
121 -- the insert dml. Presently, if the entity has a corresponding primary
122 -- key which is maintained by an associating sequence, the primary key for
123 -- the entity will be populated with the next sequence value in
124 -- preparation for the insert dml.
125 --
126 -- Pre Conditions:
127 -- This is an internal procedure which is called from the ins procedure.
128 --
129 -- In Parameters:
130 -- A Pl/Sql record structre.
131 --
132 -- Post Success:
133 -- Processing continues.
134 --
135 -- Post Failure:
136 -- If an error has occurred, an error message and exception will be raised
137 -- but not handled.
138 --
139 -- Developer Implementation Notes:
140 -- Any pre-processing required before the insert dml is issued should be
141 -- coded within this procedure. As stated above, a good example is the
142 -- generation of a primary key number via a corresponding sequence.
143 -- It is important to note that any 3rd party maintenance should be reviewed
144 -- before placing in this procedure.
145 --
146 -- Access Status:
147 -- Internal Table Handler Use Only.
148 --
149 -- {End Of Comments}
150 -- ----------------------------------------------------------------------------
151 Procedure pre_insert(p_rec in out ssp_stp_shd.g_rec_type) is
152 --
153 l_proc varchar2(72) := g_package||'pre_insert';
154 --
155 Cursor C_Sel1 is select ssp_stoppages_s.nextval from sys.dual;
156 --
157 Begin
158 hr_utility.set_location('Entering:'||l_proc, 5);
159 --
160 --
161 -- Select the next sequence number
162 --
163 Open C_Sel1;
164 Fetch C_Sel1 Into p_rec.stoppage_id;
165 Close C_Sel1;
166 --
167 hr_utility.set_location(' Leaving:'||l_proc, 10);
168 End pre_insert;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |-----------------------------< post_insert >------------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 -- This private procedure contains any processing which is required after the
177 -- insert dml.
178 --
179 -- Pre Conditions:
180 -- This is an internal procedure which is called from the ins procedure.
181 --
182 -- In Parameters:
183 -- A Pl/Sql record structre.
184 --
185 -- Post Success:
186 -- Processing continues.
187 --
188 -- Post Failure:
189 -- If an error has occurred, an error message and exception will be raised
190 -- but not handled.
191 --
192 -- Developer Implementation Notes:
193 -- Any post-processing required after the insert dml is issued should be
194 -- coded within this procedure. It is important to note that any 3rd party
195 -- maintenance should be reviewed before placing in this procedure.
196 --
197 -- Access Status:
198 -- Internal Table Handler Use Only.
199 --
200 -- {End Of Comments}
201 -- ----------------------------------------------------------------------------
202 Procedure post_insert(p_rec in ssp_stp_shd.g_rec_type) is
203 --
204 l_proc varchar2(72) := g_package||'post_insert';
205 --
206 Begin
207 hr_utility.set_location('Entering:'||l_proc, 5);
208 --
209 hr_utility.set_location(' Leaving:'||l_proc, 10);
210 End post_insert;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |---------------------------------< ins >----------------------------------|
214 -- ----------------------------------------------------------------------------
215 Procedure ins
216 (
217 p_rec in out ssp_stp_shd.g_rec_type,
218 p_validate in boolean default false
219 ) is
220 --
221 l_proc varchar2(72) := g_package||'ins';
222 --
223 Begin
224 hr_utility.set_location('Entering:'||l_proc, 5);
225 --
226 -- Determine if the business process is to be validated.
227 --
228 If p_validate then
229 --
230 -- Issue the savepoint.
231 --
232 SAVEPOINT ins_ssp_stp;
233 End If;
234 --
235 -- Call the supporting insert validate operations
236 --
237 ssp_stp_bus.insert_validate(p_rec);
238 --
239 -- Call the supporting pre-insert operation
240 --
241 pre_insert(p_rec);
242 --
243 -- Insert the row
244 --
245 insert_dml(p_rec);
246 --
247 -- Call the supporting post-insert operation
248 --
249 post_insert(p_rec);
250 --
251 -- If we are validating then raise the Validate_Enabled exception
252 --
253 If p_validate then
254 Raise HR_Api.Validate_Enabled;
255 End If;
256 --
257 hr_utility.set_location(' Leaving:'||l_proc, 10);
258 Exception
259 When HR_Api.Validate_Enabled Then
260 --
261 -- As the Validate_Enabled exception has been raised
262 -- we must rollback to the savepoint
263 --
264 ROLLBACK TO ins_ssp_stp;
265 end ins;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |---------------------------------< ins >----------------------------------|
269 -- ----------------------------------------------------------------------------
270 Procedure ins
271 (
272 p_stoppage_id out number,
273 p_object_version_number out number,
274 p_reason_id in number,
275 p_withhold_from in date,
276 p_withhold_to in date default null,
277 p_absence_attendance_id in number default null,
278 p_maternity_id in number default null,
279 p_user_entered in varchar2 default 'Y',
280 p_override_stoppage in varchar2 default 'N',
281 p_employee_notified in varchar2 default 'N',
282 p_validate in boolean default false
283 ) is
284 --
285 l_rec ssp_stp_shd.g_rec_type;
286 l_proc varchar2(72) := g_package||'ins';
287 --
288 Begin
289 hr_utility.set_location('Entering:'||l_proc, 5);
290 --
291 -- Call conversion function to turn arguments into the
292 -- p_rec structure.
293 --
294 l_rec :=
295 ssp_stp_shd.convert_args
296 (
297 null,
298 null,
299 p_absence_attendance_id,
300 p_maternity_id,
301 p_reason_id,
302 p_user_entered,
303 p_override_stoppage,
304 p_employee_notified,
305 p_withhold_from,
306 p_withhold_to
307 );
308 --
309 -- Having converted the arguments into the ssp_stp_rec
310 -- plsql record structure we call the corresponding record business process.
311 --
312 ins(l_rec, p_validate);
313 --
314 -- As the primary key argument(s)
315 -- are specified as an OUT's we must set these values.
316 --
317 p_stoppage_id := l_rec.stoppage_id;
318 p_object_version_number := l_rec.object_version_number;
319 --
320 hr_utility.set_location(' Leaving:'||l_proc, 10);
321 End ins;
322 --
323 end ssp_stp_ins;