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