DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TAH_INS

Source


1 Package Body pqh_tah_ins as
2 /* $Header: pqtahrhi.pkb 120.2 2005/12/21 11:27:52 hpandya noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_tah_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_approval_history_id_i  number   default null;
14 g_transaction_history_id_i  number   default null;
15 --
16 -- ----------------------------------------------------------------------------
17 -- |------------------------< set_base_key_value >----------------------------|
18 -- ----------------------------------------------------------------------------
19 procedure set_base_key_value
20   (p_approval_history_id  in  number
21   ,p_transaction_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_tah_ins.g_approval_history_id_i := p_approval_history_id;
29   pqh_tah_ins.g_transaction_history_id_i := p_transaction_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_tah_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_approval_history
91   --
92   insert into pqh_ss_approval_history
93       (approval_history_id
94       ,transaction_history_id
95       ,transaction_effective_date
96       ,action
97       ,user_name
98       ,transaction_item_type
99       ,transaction_item_key
100       ,effective_date_option
101       ,orig_system
102       ,orig_system_id
103       ,notification_id
104       ,user_comment
105       )
106   Values
107     (p_rec.approval_history_id
108     ,p_rec.transaction_history_id
109     ,p_rec.transaction_effective_date
110     ,p_rec.action
111     ,p_rec.user_name
112     ,p_rec.transaction_item_type
113     ,p_rec.transaction_item_key
114     ,p_rec.effective_date_option
115     ,p_rec.orig_system
116     ,p_rec.orig_system_id
117     ,p_rec.notification_id
118     ,p_rec.user_comment
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_tah_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_tah_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_tah_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_tah_shd.g_rec_type
184   ) is
185 --
186   -- Cursor C_Sel1 is select pqh_ss_approval_history_s.nextval from sys.dual;
187 --
188   Cursor C_Sel2 is
189     Select null
190       from pqh_ss_approval_history
191      where approval_history_id = pqh_tah_ins.g_approval_history_id_i
192      AND transaction_history_id = pqh_tah_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_tah_ins.g_approval_history_id_i is not null AND
201       pqh_tah_ins.g_transaction_history_id_i is not null) Then
202     --
203     -- Verify registered primary key values not already in use
204     --
205     /* Open C_Sel2;
206     Fetch C_Sel2 into l_exists;
207     If C_Sel2%found Then
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_approval_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.approval_history_id := pqh_tah_ins.g_approval_history_id_i;
220     pqh_tah_ins.g_approval_history_id_i := null;
221     p_rec.transaction_history_id := pqh_tah_ins.g_transaction_history_id_i;
222     pqh_tah_ins.g_transaction_history_id_i := null;
223   Else
224     NULL;
225   End If;
226   --
227   hr_utility.set_location(' Leaving:'||l_proc, 10);
228 End pre_insert;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |-----------------------------< post_insert >------------------------------|
232 -- ----------------------------------------------------------------------------
233 -- {Start Of Comments}
234 --
235 -- Description:
236 --   This private procedure contains any processing which is required after
237 --   the insert dml.
238 --
239 -- Prerequisites:
240 --   This is an internal procedure which is called from the ins procedure.
241 --
242 -- In Parameters:
243 --   A Pl/Sql record structre.
244 --
245 -- Post Success:
246 --   Processing continues.
247 --
248 -- Post Failure:
249 --   If an error has occurred, an error message and exception will be raised
250 --   but not handled.
251 --
252 -- Developer Implementation Notes:
253 --   Any post-processing required after the insert dml is issued should be
254 --   coded within this procedure. It is important to note that any 3rd party
255 --   maintenance should be reviewed before placing in this procedure.
256 --
257 -- Access Status:
258 --   Internal Row Handler Use Only.
259 --
260 -- {End Of Comments}
261 -- ----------------------------------------------------------------------------
262 Procedure post_insert
263   (p_rec                          in pqh_tah_shd.g_rec_type
264   ) is
265 --
266   l_proc  varchar2(72) := g_package||'post_insert';
267 --
268 Begin
269   hr_utility.set_location('Entering:'||l_proc, 5);
270   begin
271     --
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_APPROVAL_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_tah_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   pqh_tah_bus.insert_validate
302      (p_rec
303      );
304   --
305   -- Call to raise any errors on multi-message list
306   hr_multi_message.end_validation_set;
307   --
308   -- Call the supporting pre-insert operation
309   --
310   pqh_tah_ins.pre_insert(p_rec);
311   --
312   -- Insert the row
313   --
314   pqh_tah_ins.insert_dml(p_rec);
315   --
316   -- Call the supporting post-insert operation
317   --
318   pqh_tah_ins.post_insert
319      (p_rec
320      );
321   --
322   -- Call to raise any errors on multi-message list
323   hr_multi_message.end_validation_set;
324   --
325   hr_utility.set_location('Leaving:'||l_proc, 20);
326 end ins;
327 --
328 -- ----------------------------------------------------------------------------
329 -- |---------------------------------< ins >----------------------------------|
330 -- ----------------------------------------------------------------------------
331 Procedure ins
332   (p_transaction_effective_date     in     date     default null
333   ,p_action                         in     varchar2 default null
334   ,p_user_name                      in     varchar2 default null
335   ,p_transaction_item_type          in     varchar2 default null
336   ,p_transaction_item_key           in     varchar2 default null
337   ,p_effective_date_option          in     varchar2 default null
338   ,p_orig_system                    in     varchar2 default null
339   ,p_orig_system_id                 in     number   default null
340   ,p_notification_id                in     number   default null
341   ,p_user_comment                   in     varchar2 default null
342   ,p_approval_history_id               out nocopy number
343   ,p_transaction_history_id            out nocopy number
344   ) is
345 --
346   l_rec   pqh_tah_shd.g_rec_type;
347   l_proc  varchar2(72) := g_package||'ins';
348 --
349 Begin
350   hr_utility.set_location('Entering:'||l_proc, 5);
351   --
352   -- Call conversion function to turn arguments into the
353   -- p_rec structure.
354   --
355   l_rec :=
356   pqh_tah_shd.convert_args
357     (null
358     ,null
359     ,p_transaction_effective_date
360     ,p_action
361     ,p_user_name
362     ,p_transaction_item_type
363     ,p_transaction_item_key
364     ,p_effective_date_option
365     ,p_orig_system
366     ,p_orig_system_id
367     ,p_notification_id
368     ,p_user_comment
369     );
370   --
371   -- Having converted the arguments into the pqh_tah_rec
372   -- plsql record structure we call the corresponding record business process.
373   --
374   pqh_tah_ins.ins
375      (l_rec
376      );
377   --
378   -- As the primary key argument(s)
379   -- are specified as an OUT's we must set these values.
380   --
381   p_approval_history_id := l_rec.approval_history_id;
382   p_transaction_history_id := l_rec.transaction_history_id;
383   --
384   --
385   hr_utility.set_location(' Leaving:'||l_proc, 10);
386 End ins;
387 --
388 end pqh_tah_ins;