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