DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_NRE_INS

Source


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