DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CEF_INS

Source


1 Package Body pqh_cef_ins as
2 /* $Header: pqcefrhi.pkb 120.2 2005/10/12 20:18:19 srajakum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_cef_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 --      perform dml).
21 --   3) To insert the row into the schema.
22 --   4) To trap any constraint violations that may have occurred.
23 --   5) To raise any other errors.
24 --
25 -- Prerequisites:
26 --   This is an internal private procedure which must be called from the ins
27 --   procedure and must have all mandatory attributes set (except the
28 --   object_version_number which is initialised within this procedure).
29 --
30 -- In Parameters:
31 --   A Pl/Sql record structre.
32 --
33 -- Post Success:
34 --   The specified row will be inserted into the schema.
35 --
36 -- Post Failure:
37 --   On the insert dml failure it is important to note that we always reset the
38 --   If a check, unique or parent integrity constraint violation is raised the
39 --   constraint_error procedure will be called.
40 --   If any other error is reported, the error will be raised after the
41 --
42 -- Developer Implementation Notes:
43 --   None.
44 --
45 -- Access Status:
46 --   Internal Row Handler Use Only.
47 --
48 -- {End Of Comments}
49 -- ----------------------------------------------------------------------------
50 Procedure insert_dml(p_rec in out nocopy pqh_cef_shd.g_rec_type) is
51 --
52   l_proc  varchar2(72) := g_package||'insert_dml';
53 --
54 Begin
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: pqh_copy_entity_functions
60   --
61   insert into pqh_copy_entity_functions
62   (	copy_entity_function_id,
63 	table_route_id,
64 	function_type_cd,
65 	pre_copy_function_name,
66 	copy_function_name,
67 	post_copy_function_name,
68 	object_version_number,
69 	context
70   )
71   Values
72   (	p_rec.copy_entity_function_id,
73 	p_rec.table_route_id,
74 	p_rec.function_type_cd,
75 	p_rec.pre_copy_function_name,
76 	p_rec.copy_function_name,
77 	p_rec.post_copy_function_name,
78 	p_rec.object_version_number,
79 	p_rec.context
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     pqh_cef_shd.constraint_error
88       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
89   When hr_api.parent_integrity_violated Then
90     -- Parent integrity has been violated
91     pqh_cef_shd.constraint_error
92       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93   When hr_api.unique_integrity_violated Then
94     -- Unique integrity has been violated
95     pqh_cef_shd.constraint_error
96       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97   When Others Then
98     Raise;
99 End insert_dml;
100 --
101 -- ----------------------------------------------------------------------------
102 -- |------------------------------< pre_insert >------------------------------|
103 -- ----------------------------------------------------------------------------
104 -- {Start Of Comments}
105 --
106 -- Description:
107 --   This private procedure contains any processing which is required before
108 --   the insert dml. Presently, if the entity has a corresponding primary
109 --   key which is maintained by an associating sequence, the primary key for
110 --   the entity will be populated with the next sequence value in
111 --   preparation for the insert dml.
112 --
113 -- Prerequisites:
114 --   This is an internal procedure which is called from the ins procedure.
115 --
116 -- In Parameters:
117 --   A Pl/Sql record structre.
118 --
119 -- Post Success:
120 --   Processing continues.
121 --
122 -- Post Failure:
123 --   If an error has occurred, an error message and exception will be raised
124 --   but not handled.
125 --
126 -- Developer Implementation Notes:
127 --   Any pre-processing required before the insert dml is issued should be
128 --   coded within this procedure. As stated above, a good example is the
129 --   generation of a primary key number via a corresponding sequence.
130 --   It is important to note that any 3rd party maintenance should be reviewed
131 --   before placing in this procedure.
132 --
133 -- Access Status:
134 --   Internal Row Handler Use Only.
135 --
136 -- {End Of Comments}
137 -- ----------------------------------------------------------------------------
138 Procedure pre_insert(p_rec  in out nocopy pqh_cef_shd.g_rec_type) is
139 --
140   l_proc  varchar2(72) := g_package||'pre_insert';
141 --
142   Cursor C_Sel1 is select pqh_copy_entity_functions_s.nextval from sys.dual;
143 --
144 Begin
145   hr_utility.set_location('Entering:'||l_proc, 5);
146   --
147   --
148   -- Select the next sequence number
149   --
150   Open C_Sel1;
151   Fetch C_Sel1 Into p_rec.copy_entity_function_id;
152   Close C_Sel1;
153   --
154   hr_utility.set_location(' Leaving:'||l_proc, 10);
155 End pre_insert;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |-----------------------------< post_insert >------------------------------|
159 -- ----------------------------------------------------------------------------
160 -- {Start Of Comments}
161 --
162 -- Description:
163 --   This private procedure contains any processing which is required after the
164 --   insert dml.
165 --
166 -- Prerequisites:
167 --   This is an internal procedure which is called from the ins procedure.
168 --
169 -- In Parameters:
170 --   A Pl/Sql record structre.
171 --
172 -- Post Success:
173 --   Processing continues.
174 --
175 -- Post Failure:
176 --   If an error has occurred, an error message and exception will be raised
177 --   but not handled.
178 --
179 -- Developer Implementation Notes:
180 --   Any post-processing required after the insert dml is issued should be
181 --   coded within this procedure. It is important to note that any 3rd party
182 --   maintenance should be reviewed before placing in this procedure.
183 --
184 -- Access Status:
185 --   Internal Row Handler Use Only.
186 --
187 -- {End Of Comments}
188 -- ----------------------------------------------------------------------------
189 Procedure post_insert(
190 p_effective_date in date,p_rec in pqh_cef_shd.g_rec_type) is
191 --
192   l_proc  varchar2(72) := g_package||'post_insert';
193 --
194 Begin
195   hr_utility.set_location('Entering:'||l_proc, 5);
196 --
197   --
198   -- Start of API User Hook for post_insert.
199   --
200   begin
201     --
202     pqh_cef_rki.after_insert
203       (
204   p_copy_entity_function_id       =>p_rec.copy_entity_function_id
205  ,p_table_route_id                =>p_rec.table_route_id
206  ,p_function_type_cd              =>p_rec.function_type_cd
207  ,p_pre_copy_function_name        =>p_rec.pre_copy_function_name
208  ,p_copy_function_name            =>p_rec.copy_function_name
209  ,p_post_copy_function_name       =>p_rec.post_copy_function_name
210  ,p_object_version_number         =>p_rec.object_version_number
211  ,p_context                       =>p_rec.context
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 => 'pqh_copy_entity_functions'
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 nocopy pqh_cef_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   pqh_cef_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_copy_entity_function_id      out nocopy number,
271   p_table_route_id               in number,
272   p_function_type_cd             in varchar2         default null,
273   p_pre_copy_function_name       in varchar2         default null,
274   p_copy_function_name           in varchar2         default null,
275   p_post_copy_function_name      in varchar2         default null,
276   p_object_version_number        out nocopy number,
277   p_context                      in varchar2
278   ) is
279 --
280   l_rec	  pqh_cef_shd.g_rec_type;
281   l_proc  varchar2(72) := g_package||'ins';
282 --
283 Begin
284   hr_utility.set_location('Entering:'||l_proc, 5);
285   --
286   -- Call conversion function to turn arguments into the
287   -- p_rec structure.
288   --
289   l_rec :=
290   pqh_cef_shd.convert_args
291   (
292   null,
293   p_table_route_id,
294   p_function_type_cd,
295   p_pre_copy_function_name,
296   p_copy_function_name,
297   p_post_copy_function_name,
298   null,
299   p_context
300   );
301   --
302   -- Having converted the arguments into the pqh_cef_rec
303   -- plsql record structure we call the corresponding record business process.
304   --
305   ins(
306     p_effective_date,l_rec);
307   --
308   -- As the primary key argument(s)
309   -- are specified as an OUT's we must set these values.
310   --
311   p_copy_entity_function_id := l_rec.copy_entity_function_id;
312   p_object_version_number := l_rec.object_version_number;
313   --
314   hr_utility.set_location(' Leaving:'||l_proc, 10);
315 End ins;
316 --
317 end pqh_cef_ins;