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