DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_STB_INS

Source


1 Package Body per_stb_ins as
2 /* $Header: pestbrhi.pkb 115.0 2003/07/03 06:26:56 kavenkat noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_stb_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_setup_task_code_i  PER_RI_SETUP_TASKS.SETUP_TASK_CODE%TYPE   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_setup_task_code  in  Varchar2) 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   per_stb_ins.g_setup_task_code_i := p_setup_task_code;
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 per_stb_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: per_ri_setup_tasks
88   --
89   insert into per_ri_setup_tasks
90       (setup_task_code
91       ,workbench_item_code
92       ,setup_task_sequence
93       ,setup_task_status
94       ,setup_task_creation_date
95       ,setup_task_last_modified_date
96       ,setup_task_type
97       ,setup_task_action
98       ,object_version_number
99       )
100   Values
101     (p_rec.setup_task_code
102     ,p_rec.workbench_item_code
103     ,p_rec.setup_task_sequence
104     ,p_rec.setup_task_status
105     ,p_rec.setup_task_creation_date
106     ,p_rec.setup_task_last_modified_date
107     ,p_rec.setup_task_type
108     ,p_rec.setup_task_action
109     ,p_rec.object_version_number
110     );
111   --
112   --
113   --
114   hr_utility.set_location(' Leaving:'||l_proc, 10);
115 Exception
116   When hr_api.check_integrity_violated Then
117     -- A check constraint has been violated
118     --
119     per_stb_shd.constraint_error
120       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121   When hr_api.parent_integrity_violated Then
122     -- Parent integrity has been violated
123     --
124     per_stb_shd.constraint_error
125       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
126   When hr_api.unique_integrity_violated Then
127     -- Unique integrity has been violated
128     --
129     per_stb_shd.constraint_error
130       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
131   When Others Then
132     --
133     Raise;
134 End insert_dml;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |------------------------------< pre_insert >------------------------------|
138 -- ----------------------------------------------------------------------------
139 -- {Start Of Comments}
140 --
141 -- Description:
142 --   This private procedure contains any processing which is required before
143 --   the insert dml. Presently, if the entity has a corresponding primary
144 --   key which is maintained by an associating sequence, the primary key for
145 --   the entity will be populated with the next sequence value in
146 --   preparation for the insert dml.
147 --
148 -- Prerequisites:
149 --   This is an internal procedure which is called from the ins procedure.
150 --
151 -- In Parameters:
152 --   A Pl/Sql record structure.
153 --
154 -- Post Success:
155 --   Processing continues.
156 --
157 -- Post Failure:
158 --   If an error has occurred, an error message and exception will be raised
159 --   but not handled.
160 --
161 -- Developer Implementation Notes:
162 --   Any pre-processing required before the insert dml is issued should be
163 --   coded within this procedure. As stated above, a good example is the
164 --   generation of a primary key number via a corresponding sequence.
165 --   It is important to note that any 3rd party maintenance should be reviewed
166 --   before placing in this procedure.
167 --
168 -- Access Status:
169 --   Internal Row Handler Use Only.
170 --
171 -- {End Of Comments}
172 -- ----------------------------------------------------------------------------
173 Procedure pre_insert
174   (p_rec  in out nocopy per_stb_shd.g_rec_type
175   ) is
176 --
177   Cursor C_Sel2 is
178     Select null
179       from per_ri_setup_tasks
180      where setup_task_code =
181              per_stb_ins.g_setup_task_code_i;
182 --
183   l_proc   varchar2(72) := g_package||'pre_insert';
184   l_exists varchar2(1);
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   --
189   If (per_stb_ins.g_setup_task_code_i is not null) Then
190     --
191     -- Verify registered primary key values not already in use
192     --
193     Open C_Sel2;
194     Fetch C_Sel2 into l_exists;
195     If C_Sel2%found Then
196        Close C_Sel2;
197        --
198        -- The primary key values are already in use.
199        --
200        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
201        fnd_message.set_token('TABLE_NAME','per_ri_setup_tasks');
202        fnd_message.raise_error;
203     End If;
204     Close C_Sel2;
205     --
206     -- Use registered key values and clear globals
207     --
208     p_rec.setup_task_code :=
209       per_stb_ins.g_setup_task_code_i;
210     per_stb_ins.g_setup_task_code_i := null;
211   Else
212     --
213     -- No registerd key values, so select the next sequence number
214     --
215     -- No registerd key values, so raise error
216     --
217     hr_utility.set_message(801, 'HR_7207_API_MANDATORY_ARG');
218     hr_utility.set_message_token('API_NAME', g_package);
219     hr_utility.set_message_token('ARGUMENT', 'workbench_item_code');
220     hr_utility.raise_error;    --
221 
222   End If;
223   --
224   hr_utility.set_location(' Leaving:'||l_proc, 10);
225 End pre_insert;
226 --
227 -- ----------------------------------------------------------------------------
228 -- |-----------------------------< post_insert >------------------------------|
229 -- ----------------------------------------------------------------------------
230 -- {Start Of Comments}
231 --
232 -- Description:
233 --   This private procedure contains any processing which is required after
234 --   the insert dml.
235 --
236 -- Prerequisites:
237 --   This is an internal procedure which is called from the ins procedure.
238 --
239 -- In Parameters:
240 --   A Pl/Sql record structre.
241 --
242 -- Post Success:
243 --   Processing continues.
244 --
245 -- Post Failure:
246 --   If an error has occurred, an error message and exception will be raised
247 --   but not handled.
248 --
249 -- Developer Implementation Notes:
250 --   Any post-processing required after the insert dml is issued should be
251 --   coded within this procedure. It is important to note that any 3rd party
252 --   maintenance should be reviewed before placing in this procedure.
253 --
254 -- Access Status:
255 --   Internal Row Handler Use Only.
256 --
257 -- {End Of Comments}
258 -- ----------------------------------------------------------------------------
259 Procedure post_insert
260   (p_effective_date               in date
261   ,p_rec                          in per_stb_shd.g_rec_type
262   ) is
263 --
264   l_proc  varchar2(72) := g_package||'post_insert';
265 --
266 Begin
267   hr_utility.set_location('Entering:'||l_proc, 5);
268   begin
269     --
270     per_stb_rki.after_insert
271       (p_effective_date                => p_effective_date
272       ,p_setup_task_code               => p_rec.setup_task_code
273       ,p_workbench_item_code           => p_rec.workbench_item_code
274       ,p_setup_task_sequence           => p_rec.setup_task_sequence
275       ,p_setup_task_status             => p_rec.setup_task_status
276       ,p_setup_task_creation_date      => p_rec.setup_task_creation_date
277       ,p_setup_task_last_modified_dat  => p_rec.setup_task_last_modified_date
278       ,p_setup_task_type               => p_rec.setup_task_type
279       ,p_setup_task_action             => p_rec.setup_task_action
280       ,p_object_version_number         => p_rec.object_version_number
281       );
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 => 'PER_RI_SETUP_TASKS'
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_effective_date               in date
301   ,p_rec                          in out nocopy per_stb_shd.g_rec_type
302   ) is
303 --
304   l_proc  varchar2(72) := g_package||'ins';
305 --
306 Begin
307   hr_utility.set_location('Entering:'||l_proc, 5);
308   --
309   -- Call the supporting insert validate operations
310   --
311   per_stb_bus.insert_validate
312      (p_effective_date
313      ,p_rec
314      );
315   --
316   -- Call to raise any errors on multi-message list
317   hr_multi_message.end_validation_set;
318   --
319   -- Call the supporting pre-insert operation
320   --
321   per_stb_ins.pre_insert(p_rec);
322   --
323   -- Insert the row
324   --
325   per_stb_ins.insert_dml(p_rec);
326   --
327   -- Call the supporting post-insert operation
328   --
329   per_stb_ins.post_insert
330      (p_effective_date
331      ,p_rec
332      );
333   --
334   -- Call to raise any errors on multi-message list
335   hr_multi_message.end_validation_set;
336   --
337   hr_utility.set_location('Leaving:'||l_proc, 20);
338 end ins;
339 --
340 -- ----------------------------------------------------------------------------
341 -- |---------------------------------< ins >----------------------------------|
342 -- ----------------------------------------------------------------------------
343 Procedure ins
344   (p_effective_date               in     date
345   ,p_workbench_item_code            in     varchar2
346   ,p_setup_task_sequence            in     number
347   ,p_setup_task_status              in     varchar2 default null
348   ,p_setup_task_creation_date       in     date     default null
349   ,p_setup_task_last_modified_dat   in     date     default null
350   ,p_setup_task_type                in     varchar2 default null
351   ,p_setup_task_action              in     varchar2 default null
352   ,p_setup_task_code                   out nocopy varchar2
353   ,p_object_version_number             out nocopy number
354   ) is
355 --
356   l_rec   per_stb_shd.g_rec_type;
357   l_proc  varchar2(72) := g_package||'ins';
358 --
359 Begin
360   hr_utility.set_location('Entering:'||l_proc, 5);
361   --
362   -- Call conversion function to turn arguments into the
363   -- p_rec structure.
364   --
365   l_rec :=
366   per_stb_shd.convert_args
367     (null
368     ,p_workbench_item_code
369     ,p_setup_task_sequence
370     ,p_setup_task_status
371     ,p_setup_task_creation_date
372     ,p_setup_task_last_modified_dat
373     ,p_setup_task_type
374     ,p_setup_task_action
375     ,null
376     );
377   --
378   -- Having converted the arguments into the per_stb_rec
379   -- plsql record structure we call the corresponding record business process.
380   --
381   per_stb_ins.ins
382      (p_effective_date
383      ,l_rec
384      );
385   --
386   -- As the primary key argument(s)
387   -- are specified as an OUT's we must set these values.
388   --
389   p_setup_task_code := l_rec.setup_task_code;
390   p_object_version_number := l_rec.object_version_number;
391   --
392   hr_utility.set_location(' Leaving:'||l_proc, 10);
393 End ins;
394 --
395 end per_stb_ins;