1 Package Body pqh_tsh_ins as
2 /* $Header: pqtshrhi.pkb 120.2 2005/12/21 11:28:58 hpandya noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_tsh_ins.'; -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_transaction_history_id_i number default null;
14 g_approval_history_id_i number default null;
15 --
16 -- ----------------------------------------------------------------------------
17 -- |------------------------< set_base_key_value >----------------------------|
18 -- ----------------------------------------------------------------------------
19 procedure set_base_key_value
20 (p_transaction_history_id in number
21 ,p_approval_history_id in number) is
22 --
23 l_proc varchar2(72) := g_package||'set_base_key_value';
24 --
25 Begin
26 hr_utility.set_location('Entering:'||l_proc, 10);
27 --
28 pqh_tsh_ins.g_transaction_history_id_i := p_transaction_history_id;
29 pqh_tsh_ins.g_approval_history_id_i := p_approval_history_id;
30 --
31 hr_utility.set_location(' Leaving:'||l_proc, 20);
32 End set_base_key_value;
33 --
34 --
35 -- ----------------------------------------------------------------------------
36 -- |------------------------------< insert_dml >------------------------------|
37 -- ----------------------------------------------------------------------------
38 -- {Start Of Comments}
39 --
40 -- Description:
41 -- This procedure controls the actual dml insert logic. The processing of
42 -- this procedure are as follows:
43 -- 1) Initialise the object_version_number to 1 if the object_version_number
44 -- is defined as an attribute for this entity.
45 -- 2) To set and unset the g_api_dml status as required (as we are about to
46 -- perform dml).
47 -- 3) To insert the row into the schema.
48 -- 4) To trap any constraint violations that may have occurred.
49 -- 5) To raise any other errors.
50 --
51 -- Prerequisites:
52 -- This is an internal private procedure which must be called from the ins
53 -- procedure and must have all mandatory attributes set (except the
54 -- object_version_number which is initialised within this procedure).
55 --
56 -- In Parameters:
57 -- A Pl/Sql record structre.
58 --
59 -- Post Success:
60 -- The specified row will be inserted into the schema.
61 --
62 -- Post Failure:
63 -- On the insert dml failure it is important to note that we always reset the
64 -- g_api_dml status to false.
65 -- If a check, unique or parent integrity constraint violation is raised the
66 -- constraint_error procedure will be called.
67 -- If any other error is reported, the error will be raised after the
68 -- g_api_dml status is reset.
69 --
70 -- Developer Implementation Notes:
71 -- None.
72 --
73 -- Access Status:
74 -- Internal Row Handler Use Only.
75 --
76 -- {End Of Comments}
77 -- ----------------------------------------------------------------------------
78 Procedure insert_dml
79 (p_rec in out nocopy pqh_tsh_shd.g_rec_type
80 ) is
81 --
82 l_proc varchar2(72) := g_package||'insert_dml';
83 --
84 Begin
85 hr_utility.set_location('Entering:'||l_proc, 5);
86 --
87 --
88 --
89 --
90 -- Insert the row into: pqh_ss_trans_state_history
91 --
92 insert into pqh_ss_trans_state_history
93 (transaction_history_id
94 ,approval_history_id
95 ,creator_person_id
96 ,creator_role
97 ,status
98 ,transaction_state
99 ,effective_date
100 ,effective_date_option
101 ,last_update_role
102 ,parent_transaction_id
103 ,relaunch_function
104 ,transaction_document
105 )
106 Values
107 (p_rec.transaction_history_id
108 ,p_rec.approval_history_id
109 ,p_rec.creator_person_id
110 ,p_rec.creator_role
111 ,p_rec.status
112 ,p_rec.transaction_state
113 ,p_rec.effective_date
114 ,p_rec.effective_date_option
115 ,p_rec.last_update_role
116 ,p_rec.parent_transaction_id
117 ,p_rec.relaunch_function
118 ,p_rec.transaction_document
119 );
120 --
121 --
122 --
123 hr_utility.set_location(' Leaving:'||l_proc, 10);
124 Exception
125 When hr_api.check_integrity_violated Then
126 -- A check constraint has been violated
127 --
128 pqh_tsh_shd.constraint_error
129 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
130 When hr_api.parent_integrity_violated Then
131 -- Parent integrity has been violated
132 --
133 pqh_tsh_shd.constraint_error
134 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
135 When hr_api.unique_integrity_violated Then
136 -- Unique integrity has been violated
137 --
138 pqh_tsh_shd.constraint_error
139 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
140 When Others Then
141 --
142 Raise;
143 End insert_dml;
144 --
145 -- ----------------------------------------------------------------------------
146 -- |------------------------------< pre_insert >------------------------------|
147 -- ----------------------------------------------------------------------------
148 -- {Start Of Comments}
149 --
150 -- Description:
151 -- This private procedure contains any processing which is required before
152 -- the insert dml. Presently, if the entity has a corresponding primary
153 -- key which is maintained by an associating sequence, the primary key for
154 -- the entity will be populated with the next sequence value in
155 -- preparation for the insert dml.
156 --
157 -- Prerequisites:
158 -- This is an internal procedure which is called from the ins procedure.
159 --
160 -- In Parameters:
161 -- A Pl/Sql record structure.
162 --
163 -- Post Success:
164 -- Processing continues.
165 --
166 -- Post Failure:
167 -- If an error has occurred, an error message and exception will be raised
168 -- but not handled.
169 --
170 -- Developer Implementation Notes:
171 -- Any pre-processing required before the insert dml is issued should be
172 -- coded within this procedure. As stated above, a good example is the
173 -- generation of a primary key number via a corresponding sequence.
174 -- It is important to note that any 3rd party maintenance should be reviewed
175 -- before placing in this procedure.
176 --
177 -- Access Status:
178 -- Internal Row Handler Use Only.
179 --
180 -- {End Of Comments}
181 -- ----------------------------------------------------------------------------
182 Procedure pre_insert
183 (p_rec in out nocopy pqh_tsh_shd.g_rec_type
184 ) is
185 --
186 -- Cursor C_Sel1 is select pqh_ss_trans_state_history_s.nextval from sys.dual;
187 --
188 Cursor C_Sel2 is
189 Select null
190 from pqh_ss_trans_state_history
191 where transaction_history_id = pqh_tsh_ins.g_transaction_history_id_i
192 and approval_history_id = pqh_tsh_ins.g_approval_history_id_i;
193 --
194 l_proc varchar2(72) := g_package||'pre_insert';
195 l_exists varchar2(1);
196 --
197 Begin
198 hr_utility.set_location('Entering:'||l_proc, 5);
199
200 --
201 If (pqh_tsh_ins.g_transaction_history_id_i is not null AND
202 pqh_tsh_ins.g_approval_history_id_i is not null) Then
203 --
204 -- Verify registered primary key values not already in use
205 --
206 Open C_Sel2;
207 Fetch C_Sel2 into l_exists;
208 If C_Sel2%found Then
209 --
210 -- The primary key values are already in use.
211 --
212 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
213 fnd_message.set_token('TABLE_NAME','pqh_ss_trans_state_history');
214 fnd_message.raise_error;
215 End If;
216 Close C_Sel2;
217 --
218 -- Use registered key values and clear globals
219 --
220 p_rec.transaction_history_id := pqh_tsh_ins.g_transaction_history_id_i;
221 pqh_tsh_ins.g_transaction_history_id_i := null;
222 p_rec.approval_history_id := pqh_tsh_ins.g_approval_history_id_i;
223 pqh_tsh_ins.g_approval_history_id_i := null;
224 Else
225 NULL;
226 End If;
227 --
228 hr_utility.set_location(' Leaving:'||l_proc, 10);
229 End pre_insert;
230 --
231 -- ----------------------------------------------------------------------------
232 -- |-----------------------------< post_insert >------------------------------|
233 -- ----------------------------------------------------------------------------
234 -- {Start Of Comments}
235 --
236 -- Description:
237 -- This private procedure contains any processing which is required after
238 -- the insert dml.
239 --
240 -- Prerequisites:
241 -- This is an internal procedure which is called from the ins procedure.
242 --
243 -- In Parameters:
244 -- A Pl/Sql record structre.
245 --
246 -- Post Success:
247 -- Processing continues.
248 --
249 -- Post Failure:
250 -- If an error has occurred, an error message and exception will be raised
251 -- but not handled.
252 --
253 -- Developer Implementation Notes:
254 -- Any post-processing required after the insert dml is issued should be
255 -- coded within this procedure. It is important to note that any 3rd party
256 -- maintenance should be reviewed before placing in this procedure.
257 --
258 -- Access Status:
259 -- Internal Row Handler Use Only.
260 --
261 -- {End Of Comments}
262 -- ----------------------------------------------------------------------------
263 Procedure post_insert
264 (p_rec in pqh_tsh_shd.g_rec_type
265 ) is
266 --
267 l_proc varchar2(72) := g_package||'post_insert';
268 --
269 Begin
270 hr_utility.set_location('Entering:'||l_proc, 5);
271 begin
272 null;
273 --
274 exception
275 --
276 when hr_api.cannot_find_prog_unit then
277 --
278 hr_api.cannot_find_prog_unit_error
279 (p_module_name => 'PQH_SS_TRANS_STATE_HISTORY'
280 ,p_hook_type => 'AI');
281 --
282 end;
283 --
284 hr_utility.set_location(' Leaving:'||l_proc, 10);
285 End post_insert;
286 --
287 -- ----------------------------------------------------------------------------
288 -- |---------------------------------< ins >----------------------------------|
289 -- ----------------------------------------------------------------------------
290 Procedure ins
291 (p_rec in out nocopy pqh_tsh_shd.g_rec_type
292 ) is
293 --
294 l_proc varchar2(72) := g_package||'ins';
295 --
296 Begin
297 hr_utility.set_location('Entering:'||l_proc, 5);
298 --
299 -- Call the supporting insert validate operations
300 --
301
302 pqh_tsh_bus.insert_validate
303 (p_rec
304 );
305
306 --
307 -- Call to raise any errors on multi-message list
308 hr_multi_message.end_validation_set;
309 --
310 -- Call the supporting pre-insert operation
311 --
312 pqh_tsh_ins.pre_insert(p_rec);
313 --
314 -- Insert the row
315 --
316 pqh_tsh_ins.insert_dml(p_rec);
317 --
318 -- Call the supporting post-insert operation
319 --
320 pqh_tsh_ins.post_insert
321 (p_rec
322 );
323 --
324 -- Call to raise any errors on multi-message list
325 hr_multi_message.end_validation_set;
326 --
327 hr_utility.set_location('Leaving:'||l_proc, 20);
328 end ins;
329 --
330 -- ----------------------------------------------------------------------------
331 -- |---------------------------------< ins >----------------------------------|
332 -- ----------------------------------------------------------------------------
333 Procedure ins
334 (p_creator_person_id in number default null
335 ,p_creator_role in varchar2 default null
336 ,p_status in varchar2 default null
337 ,p_transaction_state in varchar2 default null
338 ,p_effective_date in date default null
339 ,p_effective_date_option in varchar2 default null
340 ,p_last_update_role in varchar2 default null
341 ,p_parent_transaction_id in number default null
342 ,p_relaunch_function in varchar2 default null
343 ,p_transaction_document in CLOB default null
344 ,p_transaction_history_id OUT NOCOPY number
345 ,p_approval_history_id OUT NOCOPY number
346 ) is
347 --
348 l_rec pqh_tsh_shd.g_rec_type;
349 l_proc varchar2(72) := g_package||'ins';
350 --
351 Begin
352 hr_utility.set_location('Entering:'||l_proc, 5);
353 --
354 -- Call conversion function to turn arguments into the
355 -- p_rec structure.
356 --
357 l_rec :=
358 pqh_tsh_shd.convert_args
359 (p_transaction_history_id
360 ,p_approval_history_id
361 ,p_creator_person_id
362 ,p_creator_role
363 ,p_status
364 ,p_transaction_state
365 ,p_effective_date
366 ,p_effective_date_option
367 ,p_last_update_role
368 ,p_parent_transaction_id
369 ,p_relaunch_function
370 ,p_transaction_document
371 );
372 --
373 -- Having converted the arguments into the pqh_tsh_rec
374 -- plsql record structure we call the corresponding record business process.
375 --
376 pqh_tsh_ins.ins
377 (l_rec
378 );
379 --
380 -- As the primary key argument(s)
381 -- are specified as an OUT's we must set these values.
382 --
383 p_transaction_history_id := l_rec.transaction_history_id;
384 p_approval_history_id := l_rec.approval_history_id;
385 --
386 --
387 hr_utility.set_location(' Leaving:'||l_proc, 10);
388 End ins;
389 --
390 end pqh_tsh_ins;