1 Package Body pqh_bgm_ins as
2 /* $Header: pqbgmrhi.pkb 115.3 2002/12/05 16:33:25 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_bgm_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:
21 -- 3) To insert the row into the schema.
18 -- 1) Initialise the object_version_number to 1 if the object_version_number
19 -- is defined as an attribute for this entity.
20 -- perform dml).
22 -- 4) To trap any constraint violations that may have occurred.
23 -- 5) To raise any other errors.
24 --
25 -- Prerequisites:
26 -- This is an internal private procedure which must be called from the ins
27 -- procedure and must have all mandatory attributes set (except the
28 -- object_version_number which is initialised within this procedure).
29 --
30 -- In Parameters:
31 -- A Pl/Sql record structre.
32 --
33 -- Post Success:
34 -- The specified row will be inserted into the schema.
35 --
36 -- Post Failure:
37 -- On the insert dml failure it is important to note that we always reset the
38 -- If a check, unique or parent integrity constraint violation is raised the
39 -- constraint_error procedure will be called.
40 -- If any other error is reported, the error will be raised after the
41 --
42 -- Developer Implementation Notes:
43 -- None.
44 --
45 -- Access Status:
46 -- Internal Row Handler Use Only.
47 --
48 -- {End Of Comments}
49 -- ----------------------------------------------------------------------------
50 Procedure insert_dml(p_rec in out nocopy pqh_bgm_shd.g_rec_type) is
51 --
52 l_proc varchar2(72) := g_package||'insert_dml';
53 --
54 Begin
55 hr_utility.set_location('Entering:'||l_proc, 5);
56 p_rec.object_version_number := 1; -- Initialise the object version
57 --
58 --
59 -- Insert the row into: pqh_budget_gl_flex_maps
60 --
61 insert into pqh_budget_gl_flex_maps
62 ( budget_gl_flex_map_id,
63 budget_id,
64 gl_account_segment,
65 payroll_cost_segment,
66 object_version_number
67 )
68 Values
69 ( p_rec.budget_gl_flex_map_id,
70 p_rec.budget_id,
71 p_rec.gl_account_segment,
72 p_rec.payroll_cost_segment,
73 p_rec.object_version_number
74 );
75 --
76 --
77 hr_utility.set_location(' Leaving:'||l_proc, 10);
78 Exception
79 When hr_api.check_integrity_violated Then
80 -- A check constraint has been violated
81 pqh_bgm_shd.constraint_error
82 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
83 When hr_api.parent_integrity_violated Then
84 -- Parent integrity has been violated
85 pqh_bgm_shd.constraint_error
86 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
87 When hr_api.unique_integrity_violated Then
88 -- Unique integrity has been violated
89 pqh_bgm_shd.constraint_error
90 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
91 When Others Then
92 Raise;
93 End insert_dml;
94 --
95 -- ----------------------------------------------------------------------------
96 -- |------------------------------< pre_insert >------------------------------|
97 -- ----------------------------------------------------------------------------
98 -- {Start Of Comments}
99 --
100 -- Description:
101 -- This private procedure contains any processing which is required before
102 -- the insert dml. Presently, if the entity has a corresponding primary
103 -- key which is maintained by an associating sequence, the primary key for
104 -- the entity will be populated with the next sequence value in
105 -- preparation for the insert dml.
106 --
107 -- Prerequisites:
108 -- This is an internal procedure which is called from the ins procedure.
109 --
110 -- In Parameters:
111 -- A Pl/Sql record structre.
112 --
113 -- Post Success:
114 -- Processing continues.
115 --
116 -- Post Failure:
117 -- If an error has occurred, an error message and exception will be raised
118 -- but not handled.
119 --
120 -- Developer Implementation Notes:
121 -- Any pre-processing required before the insert dml is issued should be
122 -- coded within this procedure. As stated above, a good example is the
123 -- generation of a primary key number via a corresponding sequence.
124 -- It is important to note that any 3rd party maintenance should be reviewed
125 -- before placing in this procedure.
126 --
127 -- Access Status:
128 -- Internal Row Handler Use Only.
129 --
130 -- {End Of Comments}
131 -- ----------------------------------------------------------------------------
132 Procedure pre_insert(p_rec in out nocopy pqh_bgm_shd.g_rec_type) is
133 --
134 l_proc varchar2(72) := g_package||'pre_insert';
135 --
136 Cursor C_Sel1 is select pqh_budget_gl_flex_maps_s.nextval from sys.dual;
137 --
138 Begin
139 hr_utility.set_location('Entering:'||l_proc, 5);
140 --
141 --
142 -- Select the next sequence number
143 --
144 Open C_Sel1;
145 Fetch C_Sel1 Into p_rec.budget_gl_flex_map_id;
146 Close C_Sel1;
147 --
148 hr_utility.set_location(' Leaving:'||l_proc, 10);
149 End pre_insert;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |-----------------------------< post_insert >------------------------------|
153 -- ----------------------------------------------------------------------------
154 -- {Start Of Comments}
155 --
156 -- Description:
157 -- This private procedure contains any processing which is required after the
158 -- insert dml.
159 --
160 -- Prerequisites:
161 -- This is an internal procedure which is called from the ins procedure.
162 --
163 -- In Parameters:
167 -- Processing continues.
164 -- A Pl/Sql record structre.
165 --
166 -- Post Success:
168 --
169 -- Post Failure:
170 -- If an error has occurred, an error message and exception will be raised
171 -- but not handled.
172 --
173 -- Developer Implementation Notes:
174 -- Any post-processing required after the insert dml is issued should be
175 -- coded within this procedure. It is important to note that any 3rd party
176 -- maintenance should be reviewed before placing in this procedure.
177 --
178 -- Access Status:
179 -- Internal Row Handler Use Only.
180 --
181 -- {End Of Comments}
182 -- ----------------------------------------------------------------------------
183 Procedure post_insert(p_rec in pqh_bgm_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_bgm_rki.after_insert
196 (
197 p_budget_gl_flex_map_id =>p_rec.budget_gl_flex_map_id
201 ,p_object_version_number =>p_rec.object_version_number
198 ,p_budget_id =>p_rec.budget_id
199 ,p_gl_account_segment =>p_rec.gl_account_segment
200 ,p_payroll_cost_segment =>p_rec.payroll_cost_segment
202 );
203 --
204 exception
205 --
206 when hr_api.cannot_find_prog_unit then
207 --
208 hr_api.cannot_find_prog_unit_error
209 (p_module_name => 'pqh_budget_gl_flex_maps'
210 ,p_hook_type => 'AI');
211 --
212 end;
213 --
214 -- End of API User Hook for post_insert.
215 --
216 --
217 hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End post_insert;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |---------------------------------< ins >----------------------------------|
222 -- ----------------------------------------------------------------------------
223 Procedure ins
224 (
225 p_rec in out nocopy pqh_bgm_shd.g_rec_type
226 ) is
227 --
228 l_proc varchar2(72) := g_package||'ins';
229 --
230 Begin
231 hr_utility.set_location('Entering:'||l_proc, 5);
232 --
233 -- Call the supporting insert validate operations
234 --
235 pqh_bgm_bus.insert_validate(p_rec);
236 --
237 -- Call the supporting pre-insert operation
238 --
239 pre_insert(p_rec);
240 --
241 -- Insert the row
242 --
243 insert_dml(p_rec);
244 --
245 -- Call the supporting post-insert operation
246 --
247 post_insert(p_rec);
248 end ins;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |---------------------------------< ins >----------------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure ins
254 (
255 p_budget_gl_flex_map_id out nocopy number,
256 p_budget_id in number,
257 p_gl_account_segment in varchar2,
258 p_payroll_cost_segment in varchar2,
259 p_object_version_number out nocopy number
260 ) is
261 --
262 l_rec pqh_bgm_shd.g_rec_type;
263 l_proc varchar2(72) := g_package||'ins';
264 --
265 Begin
266 hr_utility.set_location('Entering:'||l_proc, 5);
267 --
268 -- Call conversion function to turn arguments into the
269 -- p_rec structure.
270 --
271 l_rec :=
272 pqh_bgm_shd.convert_args
273 (
274 null,
275 p_budget_id,
276 p_gl_account_segment,
277 p_payroll_cost_segment,
278 null
279 );
280 --
281 -- Having converted the arguments into the pqh_bgm_rec
282 -- plsql record structure we call the corresponding record business process.
283 --
284 ins(l_rec);
285 --
286 -- As the primary key argument(s)
287 -- are specified as an OUT's we must set these values.
288 --
289 p_budget_gl_flex_map_id := l_rec.budget_gl_flex_map_id;
290 p_object_version_number := l_rec.object_version_number;
291 --
292 hr_utility.set_location(' Leaving:'||l_proc, 10);
293 End ins;
294 --
295 end pqh_bgm_ins;