DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TXH_INS

Source


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