DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_NLA_INS

Source


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