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