1 Package Body pqh_tem_ins as
2 /* $Header: pqtemrhi.pkb 120.5 2011/04/28 09:32:18 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_tem_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 pqh_tem_shd.g_rec_type) is
48 --
49 l_proc varchar2(72) := g_package||'insert_dml';
50 --
51 Begin
52 hr_utility.set_location('Entering:'||l_proc, 5);
53 p_rec.object_version_number := 1; -- Initialise the object version
54 --
55 per_ric_pkg.Chk_integrity (
56 p_entity_name=> 'PQH_TEMPLATES',
57 p_ref_entity=>'PQH_TRANSACTION_CATEGORIES',
58 p_ref_column_name=>'TRANSACTION_CATEGORY_ID',
59 p_ref_col_value_number=>p_rec.transaction_category_id,
60 p_ref_col_value_varchar=>NULL,
61 p_ref_col_value_date=>NULL,
62 p_ref_type=> 'INS');
63 --
64 -- Insert the row into: pqh_templates
65 --
66 insert into pqh_templates
67 ( template_name,
68 short_name,
69 template_id,
70 attribute_only_flag,
71 enable_flag,
72 create_flag,
73 transaction_category_id,
74 under_review_flag,
75 object_version_number,
76 freeze_status_cd,
77 template_type_cd,
78 legislation_code
79 )
80 Values
81 ( p_rec.template_name,
82 p_rec.short_name,
83 p_rec.template_id,
84 p_rec.attribute_only_flag,
85 p_rec.enable_flag,
86 p_rec.create_flag,
87 p_rec.transaction_category_id,
88 p_rec.under_review_flag,
89 p_rec.object_version_number,
90 p_rec.freeze_status_cd ,
91 p_rec.template_type_cd,
92 p_rec.legislation_code
93 );
94 --
95 --
96 hr_utility.set_location(' Leaving:'||l_proc, 10);
97 Exception
98 When hr_api.check_integrity_violated Then
99 -- A check constraint has been violated
100 pqh_tem_shd.constraint_error
101 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102 When hr_api.parent_integrity_violated Then
103 -- Parent integrity has been violated
104 pqh_tem_shd.constraint_error
105 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106 When hr_api.unique_integrity_violated Then
107 -- Unique integrity has been violated
108 pqh_tem_shd.constraint_error
109 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110 When Others Then
111 Raise;
112 End insert_dml;
113 --
114 -- ----------------------------------------------------------------------------
115 -- |------------------------------< pre_insert >------------------------------|
116 -- ----------------------------------------------------------------------------
117 -- {Start Of Comments}
118 --
119 -- Description:
120 -- This private procedure contains any processing which is required before
121 -- the insert dml. Presently, if the entity has a corresponding primary
122 -- key which is maintained by an associating sequence, the primary key for
123 -- the entity will be populated with the next sequence value in
124 -- preparation for the insert dml.
125 --
126 -- Prerequisites:
127 -- This is an internal procedure which is called from the ins procedure.
128 --
129 -- In Parameters:
130 -- A Pl/Sql record structre.
131 --
132 -- Post Success:
133 -- Processing continues.
134 --
135 -- Post Failure:
136 -- If an error has occurred, an error message and exception will be raised
137 -- but not handled.
138 --
139 -- Developer Implementation Notes:
140 -- Any pre-processing required before the insert dml is issued should be
141 -- coded within this procedure. As stated above, a good example is the
142 -- generation of a primary key number via a corresponding sequence.
143 -- It is important to note that any 3rd party maintenance should be reviewed
144 -- before placing in this procedure.
145 --
146 -- Access Status:
147 -- Internal Row Handler Use Only.
148 --
149 -- {End Of Comments}
150 -- ----------------------------------------------------------------------------
151 Procedure pre_insert(p_rec in out nocopy pqh_tem_shd.g_rec_type) is
152 --
153 l_proc varchar2(72) := g_package||'pre_insert';
154 --
155 Cursor C_Sel1 is select pqh_templates_s.nextval from sys.dual;
156 --
157 Begin
158 hr_utility.set_location('Entering:'||l_proc, 5);
159 --
160 --
161 -- Select the next sequence number
162 --
163 Open C_Sel1;
164 Fetch C_Sel1 Into p_rec.template_id;
165 Close C_Sel1;
166 --
167 hr_utility.set_location(' Leaving:'||l_proc, 10);
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 pqh_tem_shd.g_rec_type) is
204 --
205 l_proc varchar2(72) := g_package||'post_insert';
206 --
207 Begin
208 hr_utility.set_location('Entering:'||l_proc, 5);
209 --
210 --
211 -- Start of API User Hook for post_insert.
212 --
213 begin
214 --
215 pqh_tem_rki.after_insert
216 (
217 p_template_name =>p_rec.template_name
218 ,p_short_name =>p_rec.short_name
219 ,p_template_id =>p_rec.template_id
220 ,p_attribute_only_flag =>p_rec.attribute_only_flag
221 ,p_enable_flag =>p_rec.enable_flag
222 ,p_create_flag =>p_rec.create_flag
223 ,p_transaction_category_id =>p_rec.transaction_category_id
224 ,p_under_review_flag =>p_rec.under_review_flag
225 ,p_object_version_number =>p_rec.object_version_number
226 ,p_freeze_status_cd =>p_rec.freeze_status_cd
227 ,p_template_type_cd =>p_rec.template_type_cd
228 ,p_legislation_code =>p_rec.legislation_code
229 ,p_effective_date =>p_effective_date
230 );
231 --
232 exception
233 --
234 when hr_api.cannot_find_prog_unit then
235 --
236 hr_api.cannot_find_prog_unit_error
237 (p_module_name => 'pqh_templates'
238 ,p_hook_type => 'AI');
239 --
240 end;
241 --
242 -- End of API User Hook for post_insert.
243 --
244 --
245 hr_utility.set_location(' Leaving:'||l_proc, 10);
246 End post_insert;
247 --
248 -- ----------------------------------------------------------------------------
249 -- |---------------------------------< ins >----------------------------------|
250 -- ----------------------------------------------------------------------------
251 Procedure ins
252 (
253 p_effective_date in date,
254 p_rec in out nocopy pqh_tem_shd.g_rec_type
255 ) is
256 --
257 l_proc varchar2(72) := g_package||'ins';
258 --
259 Begin
260 hr_utility.set_location('Entering:'||l_proc, 5);
261 --
262 -- Call the supporting insert validate operations
263 --
264 pqh_tem_bus.insert_validate(p_rec
265 ,p_effective_date);
266 --
267 -- Call the supporting pre-insert operation
268 --
269 pre_insert(p_rec);
270 --
271 -- Insert the row
272 --
273 insert_dml(p_rec);
274 --
275 -- Call the supporting post-insert operation
276 --
277 post_insert(
278 p_effective_date,p_rec);
279 end ins;
280 --
281 -- ----------------------------------------------------------------------------
282 -- |---------------------------------< ins >----------------------------------|
283 -- ----------------------------------------------------------------------------
284 Procedure ins
285 (
286 p_effective_date in date,
287 p_template_name in varchar2,
288 p_short_name in varchar2,
289 p_template_id out nocopy number,
290 p_attribute_only_flag in varchar2 default null,
291 p_enable_flag in varchar2 default 'Y',
292 p_create_flag in varchar2 default null,
293 p_transaction_category_id in number,
294 p_under_review_flag in varchar2 default null,
295 p_object_version_number out nocopy number,
296 p_freeze_status_cd in varchar2 default null,
297 p_template_type_cd in varchar2,
298 p_legislation_code in varchar2 default null
299 ) is
300 --
301 l_rec pqh_tem_shd.g_rec_type;
302 l_proc varchar2(72) := g_package||'ins';
303 --
304 Begin
305 hr_utility.set_location('Entering:'||l_proc, 5);
306 --
307 -- Call conversion function to turn arguments into the
308 -- p_rec structure.
309 --
310 l_rec :=
311 pqh_tem_shd.convert_args
312 (
313 p_template_name,
314 p_short_name,
315 null,
316 p_attribute_only_flag,
317 p_enable_flag,
318 p_create_flag,
319 p_transaction_category_id,
320 p_under_review_flag,
321 null,
322 p_freeze_status_cd,
323 p_template_type_cd,
324 p_legislation_code
325 );
326 --
327 -- Having converted the arguments into the pqh_tem_rec
328 -- plsql record structure we call the corresponding record business process.
329 --
330 ins(
331 p_effective_date,l_rec);
332 --
333 -- As the primary key argument(s)
334 -- are specified as an OUT's we must set these values.
335 --
336 p_template_id := l_rec.template_id;
337 p_object_version_number := l_rec.object_version_number;
338 --
339 hr_utility.set_location(' Leaving:'||l_proc, 10);
340 End ins;
341 --
342 end pqh_tem_ins;