DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_FTR_INS

Source


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