1 Package Body pqh_wfs_ins as
2 /* $Header: pqwfsrhi.pkb 115.7 2003/04/02 20:02:19 srajakum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_wfs_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_wfs_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_worksheet_fund_srcs
57 --
58 insert into pqh_worksheet_fund_srcs
59 ( worksheet_fund_src_id,
60 worksheet_bdgt_elmnt_id,
61 distribution_percentage,
62 cost_allocation_keyflex_id,
63 project_id,
64 award_id,
65 task_id,
66 expenditure_type,
67 organization_id,
68 object_version_number
69 )
70 Values
71 ( p_rec.worksheet_fund_src_id,
72 p_rec.worksheet_bdgt_elmnt_id,
73 p_rec.distribution_percentage,
74 p_rec.cost_allocation_keyflex_id,
75 p_rec.project_id,
76 p_rec.award_id,
77 p_rec.task_id,
78 p_rec.expenditure_type,
79 p_rec.organization_id,
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_wfs_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_wfs_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_wfs_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_wfs_shd.g_rec_type) is
140 --
141 l_proc varchar2(72) := g_package||'pre_insert';
142 --
143 Cursor C_Sel1 is select pqh_worksheet_fund_srcs_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.worksheet_fund_src_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_rec in pqh_wfs_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_wfs_rki.after_insert
203 (
204 p_worksheet_fund_src_id =>p_rec.worksheet_fund_src_id
205 ,p_worksheet_bdgt_elmnt_id =>p_rec.worksheet_bdgt_elmnt_id
206 ,p_distribution_percentage =>p_rec.distribution_percentage
207 ,p_cost_allocation_keyflex_id =>p_rec.cost_allocation_keyflex_id
208 ,p_project_id =>p_rec.project_id
209 ,p_award_id =>p_rec.award_id
210 ,p_task_id =>p_rec.task_id
211 ,p_expenditure_type =>p_rec.expenditure_type
212 ,p_organization_id =>p_rec.organization_id
213 ,p_object_version_number =>p_rec.object_version_number
214 );
215 --
216 exception
217 --
218 when hr_api.cannot_find_prog_unit then
219 --
220 hr_api.cannot_find_prog_unit_error
221 (p_module_name => 'pqh_worksheet_fund_srcs'
222 ,p_hook_type => 'AI');
223 --
224 end;
225 --
226 -- End of API User Hook for post_insert.
227 --
228 --
229 hr_utility.set_location(' Leaving:'||l_proc, 10);
230 End post_insert;
231 --
232 -- ----------------------------------------------------------------------------
233 -- |---------------------------------< ins >----------------------------------|
234 -- ----------------------------------------------------------------------------
235 Procedure ins
236 (
237 p_rec in out nocopy pqh_wfs_shd.g_rec_type
238 ) is
239 --
240 l_proc varchar2(72) := g_package||'ins';
241 --
242 Begin
243 hr_utility.set_location('Entering:'||l_proc, 5);
244 --
245 -- Call the supporting insert validate operations
246 --
247 pqh_wfs_bus.insert_validate(p_rec);
248 --
249 -- Call the supporting pre-insert operation
250 --
251 pre_insert(p_rec);
252 --
253 -- Insert the row
254 --
255 insert_dml(p_rec);
256 --
257 -- Call the supporting post-insert operation
258 --
259 post_insert(p_rec);
260 end ins;
261 --
262 -- ----------------------------------------------------------------------------
263 -- |---------------------------------< ins >----------------------------------|
264 -- ----------------------------------------------------------------------------
265 Procedure ins
266 (
267 p_worksheet_fund_src_id out nocopy number,
268 p_worksheet_bdgt_elmnt_id in number,
269 p_distribution_percentage in number default null,
270 p_cost_allocation_keyflex_id in number,
271 p_project_id in number default null,
272 p_award_id in number default null,
273 p_task_id in number default null,
274 p_expenditure_type in varchar2 default null,
275 p_organization_id in number default null,
276 p_object_version_number out nocopy number
277 ) is
278 --
279 l_rec pqh_wfs_shd.g_rec_type;
280 l_proc varchar2(72) := g_package||'ins';
281 --
282 Begin
283 hr_utility.set_location('Entering:'||l_proc, 5);
284 --
285 -- Call conversion function to turn arguments into the
286 -- p_rec structure.
287 --
288 l_rec :=
289 pqh_wfs_shd.convert_args
290 (
291 null,
292 p_worksheet_bdgt_elmnt_id,
293 p_distribution_percentage,
294 p_cost_allocation_keyflex_id,
295 p_project_id,
296 p_award_id,
297 p_task_id,
298 p_expenditure_type,
299 p_organization_id,
300 null
301 );
302 --
303 -- Having converted the arguments into the pqh_wfs_rec
304 -- plsql record structure we call the corresponding record business process.
305 --
306 ins(l_rec);
307 --
308 -- As the primary key argument(s)
309 -- are specified as an OUT's we must set these values.
310 --
311 p_worksheet_fund_src_id := l_rec.worksheet_fund_src_id;
312 p_object_version_number := l_rec.object_version_number;
313 --
314 hr_utility.set_location(' Leaving:'||l_proc, 10);
315 End ins;
316 --
317 end pqh_wfs_ins;