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