DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TKT_INS

Source


1 Package Body pqh_tkt_ins as
2 /* $Header: pqtktrhi.pkb 115.4 2002/12/12 21:44:06 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_tkt_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_tatigkeit_detail_id   number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_tatigkeit_detail_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_tkt_ins.G_TATIGKEIT_DETAIL_ID := p_tatigkeit_detail_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}
39 --   this procedure are as follows:
36 --
37 -- Description:
38 --   This procedure controls the actual dml insert logic. The processing of
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_tkt_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   p_rec.object_version_number := 1;  -- Initialise the object version
84   --
85   --
86   --
87   -- Insert the row into: pqh_de_tatigkeit_details
88   --
89   insert into pqh_de_tatigkeit_details
90       (tatigkeit_detail_id
91       ,tatigkeit_number
92       ,description
93       ,object_version_number
94       )
95   Values
96     (p_rec.tatigkeit_detail_id
97     ,p_rec.tatigkeit_number
98     ,p_rec.description
99     ,p_rec.object_version_number
100     );
101   --
102   --
103   --
104   hr_utility.set_location(' Leaving:'||l_proc, 10);
105 Exception
106   When hr_api.check_integrity_violated Then
107     -- A check constraint has been violated
108     --
109     pqh_tkt_shd.constraint_error
110       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111   When hr_api.parent_integrity_violated Then
112     -- Parent integrity has been violated
113     --
114     pqh_tkt_shd.constraint_error
115       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
116   When hr_api.unique_integrity_violated Then
117     -- Unique integrity has been violated
118     --
119     pqh_tkt_shd.constraint_error
120       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121   When Others Then
122     --
123     Raise;
124 End insert_dml;
125 --
126 -- ----------------------------------------------------------------------------
127 -- |------------------------------< pre_insert >------------------------------|
128 -- ----------------------------------------------------------------------------
129 -- {Start Of Comments}
130 --
131 -- Description:
132 --   This private procedure contains any processing which is required before
133 --   the insert dml. Presently, if the entity has a corresponding primary
134 --   key which is maintained by an associating sequence, the primary key for
135 --   the entity will be populated with the next sequence value in
136 --   preparation for the insert dml.
137 --
138 -- Prerequisites:
139 --   This is an internal procedure which is called from the ins procedure.
140 --
141 -- In Parameters:
142 --   A Pl/Sql record structure.
143 --
144 -- Post Success:
145 --   Processing continues.
146 --
147 -- Post Failure:
148 --   If an error has occurred, an error message and exception will be raised
149 --   but not handled.
150 --
151 -- Developer Implementation Notes:
152 --   Any pre-processing required before the insert dml is issued should be
153 --   coded within this procedure. As stated above, a good example is the
154 --   generation of a primary key number via a corresponding sequence.
155 --   It is important to note that any 3rd party maintenance should be reviewed
156 --   before placing in this procedure.
157 --
158 -- Access Status:
159 --   Internal Row Handler Use Only.
160 --
161 -- {End Of Comments}
162 -- ----------------------------------------------------------------------------
163 Procedure pre_insert
164   (p_rec  in out nocopy pqh_tkt_shd.g_rec_type
165   ) is
166 --
167   Cursor C_Sel1 is select pqh_de_tatigkeit_details_s.nextval from sys.dual;
168 --
169   Cursor C_Sel2 is
170     Select null
171       from pqh_de_tatigkeit_details
172      where tatigkeit_detail_id =
173              pqh_tkt_ins.G_TATIGKEIT_DETAIL_ID;
174 --
175   l_proc   varchar2(72) := g_package||'pre_insert';
176   l_exists varchar2(1);
177 --
178 Begin
179   hr_utility.set_location('Entering:'||l_proc, 5);
180   --
181   If (pqh_tkt_ins.G_TATIGKEIT_DETAIL_ID is not null) Then
182     --
183     -- Verify registered primary key values not already in use
184     --
185     Open C_Sel2;
186     Fetch C_Sel2 into l_exists;
187     If C_Sel2%found Then
191        --
188        Close C_Sel2;
189        --
190        -- The primary key values are already in use.
192        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
193        fnd_message.set_token('TABLE_NAME','pqh_de_tatigkeit_details');
194        fnd_message.raise_error;
195     End If;
196     Close C_Sel2;
197     --
198     -- Use registered key values and clear globals
199     --
200     p_rec.tatigkeit_detail_id :=
201       pqh_tkt_ins.G_TATIGKEIT_DETAIL_ID;
202     pqh_tkt_ins.G_TATIGKEIT_DETAIL_ID := null;
203   Else
204     --
205     -- No registerd key values, so select the next sequence number
206     --
207     --
208     -- Select the next sequence number
209     --
210     Open C_Sel1;
211     Fetch C_Sel1 Into p_rec.tatigkeit_detail_id;
212     Close C_Sel1;
213   End If;
214   --
215   hr_utility.set_location(' Leaving:'||l_proc, 10);
216 End pre_insert;
217 --
218 -- ----------------------------------------------------------------------------
219 -- |-----------------------------< post_insert >------------------------------|
220 -- ----------------------------------------------------------------------------
221 -- {Start Of Comments}
222 --
223 -- Description:
224 --   This private procedure contains any processing which is required after
225 --   the insert dml.
226 --
227 -- Prerequisites:
228 --   This is an internal procedure which is called from the ins procedure.
229 --
230 -- In Parameters:
231 --   A Pl/Sql record structre.
232 --
233 -- Post Success:
234 --   Processing continues.
235 --
236 -- Post Failure:
237 --   If an error has occurred, an error message and exception will be raised
238 --   but not handled.
239 --
240 -- Developer Implementation Notes:
241 --   Any post-processing required after the insert dml is issued should be
242 --   coded within this procedure. It is important to note that any 3rd party
243 --   maintenance should be reviewed before placing in this procedure.
244 --
245 -- Access Status:
246 --   Internal Row Handler Use Only.
247 --
248 -- {End Of Comments}
249 -- ----------------------------------------------------------------------------
250 Procedure post_insert
251   (p_effective_date               in date
252   ,p_rec                          in pqh_tkt_shd.g_rec_type
253   ) is
254 --
255   l_proc  varchar2(72) := g_package||'post_insert';
256 --
257 Begin
258   hr_utility.set_location('Entering:'||l_proc, 5);
259   begin
260     --
261     pqh_tkt_rki.after_insert
262       (p_effective_date              => p_effective_date
263       ,p_tatigkeit_detail_id
264       => p_rec.tatigkeit_detail_id
265       ,p_tatigkeit_number
266       => p_rec.tatigkeit_number
267       ,p_description
268       => p_rec.description
269       ,p_object_version_number
270       => p_rec.object_version_number
271       );
272     --
273   exception
274     --
275     when hr_api.cannot_find_prog_unit then
276       --
277       hr_api.cannot_find_prog_unit_error
278         (p_module_name => 'CREATE_TATIGKEIT_DETAILS'
279         ,p_hook_type   => 'AI');
280       --
281   end;
282   --
283   hr_utility.set_location(' Leaving:'||l_proc, 10);
284 End post_insert;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |---------------------------------< ins >----------------------------------|
288 -- ----------------------------------------------------------------------------
289 Procedure ins
290   (p_effective_date               in date
291   ,p_rec                          in out nocopy pqh_tkt_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_tkt_bus.insert_validate
302      (p_effective_date
303      ,p_rec
304      );
305   --
306   -- Call to raise any errors on multi-message list
307   hr_multi_message.end_validation_set;
308   --
309   -- Call the supporting pre-insert operation
310   --
311   pqh_tkt_ins.pre_insert(p_rec);
312   --
313   -- Insert the row
314   --
315   pqh_tkt_ins.insert_dml(p_rec);
316   --
317   -- Call the supporting post-insert operation
318   --
319   pqh_tkt_ins.post_insert
320      (p_effective_date
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_effective_date               in     date
335   ,p_tatigkeit_number               in     varchar2
336   ,p_description                    in     varchar2
337   ,p_tatigkeit_detail_id               out nocopy number
338   ,p_object_version_number             out nocopy number
339   ) is
340 --
341   l_rec   pqh_tkt_shd.g_rec_type;
342   l_proc  varchar2(72) := g_package||'ins';
343 --
344 Begin
345   hr_utility.set_location('Entering:'||l_proc, 5);
346   --
347   -- Call conversion function to turn arguments into the
348   -- p_rec structure.
349   --
350   l_rec :=
351   pqh_tkt_shd.convert_args
352     (null
353     ,p_tatigkeit_number
354     ,p_description
355     ,null
356     );
357   --
358   -- Having converted the arguments into the pqh_tkt_rec
359   -- plsql record structure we call the corresponding record business process.
360   --
361   pqh_tkt_ins.ins
362      (p_effective_date
363      ,l_rec
364      );
365   --
366   -- As the primary key argument(s)
367   -- are specified as an OUT's we must set these values.
368   --
369   p_tatigkeit_detail_id := l_rec.tatigkeit_detail_id;
370   p_object_version_number := l_rec.object_version_number;
371   --
372   hr_utility.set_location(' Leaving:'||l_proc, 10);
373 End ins;
374 --
375 end pqh_tkt_ins;