DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_AHC_INS

Source


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