DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_NLA_INS

Source


1 Package Body ghr_nla_ins as
2 /* $Header: ghnlarhi.pkb 115.4 1999/11/09 22:41:05 pkm ship    $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ghr_nla_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To insert the row into the schema.
21 --   3) To trap any constraint violations that may have occurred.
22 --   4) To raise any other errors.
23 --
24 -- Prerequisites:
25 --   This is an internal private procedure which must be called from the ins
26 --   procedure and must have all mandatory attributes set (except the
27 --   object_version_number which is initialised within this procedure).
28 --
29 -- In Parameters:
30 --   A Pl/Sql record structre.
31 --
32 -- Post Success:
33 --   The specified row will be inserted into the schema.
34 --
35 -- Post Failure:
36 --   If a check, unique or parent integrity constraint violation is raised the
37 --   constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 --   None.
41 --
42 -- Access Status:
43 --   Internal Row Handler Use Only.
44 --
45 -- {End Of Comments}
46 -- ----------------------------------------------------------------------------
47 Procedure insert_dml(p_rec in out ghr_nla_shd.g_rec_type) is
48 --
49   l_proc  varchar2(72) := g_package||'insert_dml';
50 --
51 Begin
52   hr_utility.set_location('Entering:'||l_proc, 5);
53   p_rec.object_version_number := 1;  -- Initialise the object version
54   --
55   --
56   -- Insert the row into: ghr_noac_las
57   --
58   insert into ghr_noac_las
59   (	noac_la_id,
60 	nature_of_action_id,
61 	lac_lookup_code,
62 	enabled_flag,
63 	date_from,
64 	date_to,
65 	object_version_number,
66 	valid_first_lac_flag,
67 	valid_second_lac_flag
68   )
69   Values
70   (	p_rec.noac_la_id,
71 	p_rec.nature_of_action_id,
72 	p_rec.lac_lookup_code,
73 	p_rec.enabled_flag,
74 	p_rec.date_from,
75 	p_rec.date_to,
76 	p_rec.object_version_number,
77 	p_rec.valid_first_lac_flag,
78 	p_rec.valid_second_lac_flag
79   );
80   --
81   --
82   hr_utility.set_location(' Leaving:'||l_proc, 10);
83 Exception
84   When hr_api.check_integrity_violated Then
85     -- A check constraint has been violated
86     ghr_nla_shd.constraint_error
87       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
88   When hr_api.parent_integrity_violated Then
89     -- Parent integrity has been violated
90     ghr_nla_shd.constraint_error
91       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
92   When hr_api.unique_integrity_violated Then
93     -- Unique integrity has been violated
94     ghr_nla_shd.constraint_error
95       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
96   When Others Then
97     Raise;
98 End insert_dml;
99 --
100 -- ----------------------------------------------------------------------------
101 -- |------------------------------< pre_insert >------------------------------|
102 -- ----------------------------------------------------------------------------
103 -- {Start Of Comments}
104 --
105 -- Description:
106 --   This private procedure contains any processing which is required before
107 --   the insert dml. Presently, if the entity has a corresponding primary
108 --   key which is maintained by an associating sequence, the primary key for
109 --   the entity will be populated with the next sequence value in
110 --   preparation for the insert dml.
111 --
112 -- Prerequisites:
113 --   This is an internal procedure which is called from the ins procedure.
114 --
115 -- In Parameters:
116 --   A Pl/Sql record structre.
117 --
118 -- Post Success:
119 --   Processing continues.
120 --
121 -- Post Failure:
122 --   If an error has occurred, an error message and exception will be raised
123 --   but not handled.
124 --
125 -- Developer Implementation Notes:
126 --   Any pre-processing required before the insert dml is issued should be
127 --   coded within this procedure. As stated above, a good example is the
128 --   generation of a primary key number via a corresponding sequence.
129 --   It is important to note that any 3rd party maintenance should be reviewed
130 --   before placing in this procedure.
131 --
132 -- Access Status:
133 --   Internal Row Handler Use Only.
134 --
135 -- {End Of Comments}
136 -- ----------------------------------------------------------------------------
137 Procedure pre_insert(p_rec  in out ghr_nla_shd.g_rec_type) is
138 --
139   l_proc  varchar2(72) := g_package||'pre_insert';
140 --
141   Cursor C_Sel1 is select ghr_noac_las_s.nextval from sys.dual;
142 --
143 Begin
144   hr_utility.set_location('Entering:'||l_proc, 5);
145   --
146   --
147   -- Select the next sequence number
148   --
149   Open C_Sel1;
150   Fetch C_Sel1 Into p_rec.noac_la_id;
151   Close C_Sel1;
152   --
153   hr_utility.set_location(' Leaving:'||l_proc, 10);
154 End pre_insert;
155 --
156 -- ----------------------------------------------------------------------------
157 -- |-----------------------------< post_insert >------------------------------|
158 -- ----------------------------------------------------------------------------
159 -- {Start Of Comments}
160 --
161 -- Description:
162 --   This private procedure contains any processing which is required after the
163 --   insert dml.
164 --
165 -- Prerequisites:
166 --   This is an internal procedure which is called from the ins procedure.
167 --
168 -- In Parameters:
169 --   A Pl/Sql record structre.
170 --
171 -- Post Success:
172 --   Processing continues.
173 --
174 -- Post Failure:
175 --   If an error has occurred, an error message and exception will be raised
176 --   but not handled.
177 --
178 -- Developer Implementation Notes:
179 --   Any post-processing required after the insert dml is issued should be
180 --   coded within this procedure. It is important to note that any 3rd party
181 --   maintenance should be reviewed before placing in this procedure.
182 --
183 -- Access Status:
184 --   Internal Row Handler Use Only.
185 --
186 -- {End Of Comments}
187 -- ----------------------------------------------------------------------------
188 Procedure post_insert(
189 p_effective_date in date,p_rec in ghr_nla_shd.g_rec_type) is
190 --
191   l_proc  varchar2(72) := g_package||'post_insert';
192 --
193 Begin
194   hr_utility.set_location('Entering:'||l_proc, 5);
195 --
196   --
197   -- Start of API User Hook for post_insert.
198   --
199   begin
200     --
201     ghr_nla_rki.after_insert
202       (
203   p_noac_la_id                    =>p_rec.noac_la_id
204  ,p_nature_of_action_id           =>p_rec.nature_of_action_id
205  ,p_lac_lookup_code               =>p_rec.lac_lookup_code
206  ,p_enabled_flag                  =>p_rec.enabled_flag
207  ,p_date_from                     =>p_rec.date_from
208  ,p_date_to                       =>p_rec.date_to
209  ,p_object_version_number         =>p_rec.object_version_number
210  ,p_valid_first_lac_flag          =>p_rec.valid_first_lac_flag
211  ,p_valid_second_lac_flag         =>p_rec.valid_second_lac_flag
212  ,p_effective_date                =>p_effective_date
213       );
214     --
215   exception
216     --
217     when hr_api.cannot_find_prog_unit then
218       --
219       hr_api.cannot_find_prog_unit_error
220         (p_module_name => 'ghr_noac_las'
221         ,p_hook_type   => 'AI');
222       --
223   end;
224   --
225   -- End of API User Hook for post_insert.
226   --
227   --
228   hr_utility.set_location(' Leaving:'||l_proc, 10);
229 End post_insert;
230 --
231 -- ----------------------------------------------------------------------------
232 -- |---------------------------------< ins >----------------------------------|
233 -- ----------------------------------------------------------------------------
234 Procedure ins
235   (
236   p_effective_date in date,
237   p_rec        in out ghr_nla_shd.g_rec_type
238   ) is
239 --
240   l_proc  varchar2(72) := g_package||'ins';
241 --
242 Begin
243   hr_utility.set_location('Entering:'||l_proc, 5);
244   --
245   -- Call the supporting insert validate operations
246   --
247   ghr_nla_bus.insert_validate(p_rec
248   ,p_effective_date);
249   --
250   -- Call the supporting pre-insert operation
251   --
252   pre_insert(p_rec);
253   --
254   -- Insert the row
255   --
256   insert_dml(p_rec);
257   --
258   -- Call the supporting post-insert operation
259   --
260   post_insert(
261 p_effective_date,p_rec);
262 end ins;
263 --
264 -- ----------------------------------------------------------------------------
265 -- |---------------------------------< ins >----------------------------------|
266 -- ----------------------------------------------------------------------------
267 Procedure ins
268   (
269   p_effective_date in date,
270   p_noac_la_id                   out number,
271   p_nature_of_action_id          in number,
272   p_lac_lookup_code              in varchar2,
273   p_enabled_flag                 in varchar2,
274   p_date_from                    in date,
275   p_date_to                      in date             default null,
276   p_object_version_number        out number,
277   p_valid_first_lac_flag         in varchar2,
278   p_valid_second_lac_flag        in varchar2
279   ) is
280 --
281   l_rec	  ghr_nla_shd.g_rec_type;
282   l_proc  varchar2(72) := g_package||'ins';
283 --
284 Begin
285   hr_utility.set_location('Entering:'||l_proc, 5);
286   --
287   -- Call conversion function to turn arguments into the
288   -- p_rec structure.
289   --
290   l_rec :=
291   ghr_nla_shd.convert_args
292   (
293   null,
294   p_nature_of_action_id,
295   p_lac_lookup_code,
296   p_enabled_flag,
297   p_date_from,
298   p_date_to,
299   null,
300   p_valid_first_lac_flag,
301   p_valid_second_lac_flag
302   );
303   --
304   -- Having converted the arguments into the ghr_nla_rec
305   -- plsql record structure we call the corresponding record business process.
306   --
307   ins(
308     p_effective_date,l_rec);
309   --
310   -- As the primary key argument(s)
311   -- are specified as an OUT's we must set these values.
312   --
313   p_noac_la_id := l_rec.noac_la_id;
314   p_object_version_number := l_rec.object_version_number;
315   --
316   hr_utility.set_location(' Leaving:'||l_proc, 10);
317 End ins;
318 --
319 end ghr_nla_ins;