1 Package Body pqh_fyn_ins as
2 /* $Header: pqfynrhi.pkb 115.6 2002/12/06 18:06:27 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_fyn_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_fyn_shd.g_rec_type) is
48 --
49 l_proc varchar2(72) := g_package||'insert_dml';
50
51 l_count number(9) := 0;
52
53 -- check if the combo already exists and only then insert record
54 CURSOR csr_cnt_combo(p_transaction_category_id IN number,
55 p_transaction_id IN number,
56 p_notification_event_cd IN varchar2,
57 p_notified_type_cd IN varchar2,
58 p_notified_name IN varchar2) IS
59 SELECT COUNT(*)
60 FROM pqh_fyi_notify
61 WHERE transaction_category_id = p_transaction_category_id
62 AND transaction_id = p_transaction_id
63 AND notification_event_cd = p_notification_event_cd
64 AND NVL(notified_type_cd,'X') = NVL(p_notified_type_cd,'X')
65 AND NVL(notified_name,'X') = NVL(p_notified_name,'X')
66 AND NVL(status,'X') <> 'SENT';
67 --
68 Begin
69 hr_utility.set_location('Entering:'||l_proc, 5);
70 p_rec.object_version_number := 1; -- Initialise the object version
71 --
72
73 --
74 -- check for the combo before inserting
75 --
76 OPEN csr_cnt_combo(p_transaction_category_id => p_rec.transaction_category_id,
77 p_transaction_id => p_rec.transaction_id,
78 p_notification_event_cd => p_rec.notification_event_cd,
79 p_notified_type_cd => p_rec.notified_type_cd,
80 p_notified_name => p_rec.notified_name );
81 FETCH csr_cnt_combo INTO l_count;
82
83 CLOSE csr_cnt_combo;
84 --
85 hr_utility.set_location(' fyi_notified_id: '||p_rec.fyi_notified_id, 6);
86 hr_utility.set_location(' transaction_category_id: '||p_rec.transaction_category_id, 7);
87 hr_utility.set_location(' transaction_id: '||p_rec.transaction_id, 8);
88 hr_utility.set_location(' notification_event_cd: '||p_rec.notification_event_cd, 9);
89 hr_utility.set_location(' notified_type_cd: '||p_rec.notified_type_cd, 10);
90 hr_utility.set_location(' notified_name: '||p_rec.notified_name, 11);
91 hr_utility.set_location(' notification_date: '||p_rec.notification_date, 12);
92 hr_utility.set_location(' status: '||p_rec.status, 13);
93 hr_utility.set_location(' object_version_number: '||p_rec.object_version_number, 14);
94 hr_utility.set_location(' COUNT COMBO: '||l_count, 15);
95 --
96 --
97 -- Insert the row into: pqh_fyi_notify ONLY if the row does not exists i.e l_count = 0
98 --
99
100 if NVL(l_count,0) = 0 THEN
101 --
102 hr_utility.set_location('Inserting INTO pqh_fyi_notify ....',16);
103
104 insert into pqh_fyi_notify
105 ( fyi_notified_id,
106 transaction_category_id,
107 transaction_id,
108 notification_event_cd,
109 notified_type_cd,
110 notified_name,
111 notification_date,
112 status,
113 object_version_number
114 )
115 Values
116 ( p_rec.fyi_notified_id,
117 p_rec.transaction_category_id,
118 p_rec.transaction_id,
119 p_rec.notification_event_cd,
120 p_rec.notified_type_cd,
121 p_rec.notified_name,
122 p_rec.notification_date,
123 p_rec.status,
124 p_rec.object_version_number
125 );
126
127 --
128 end if;
129 --
130 hr_utility.set_location(' Leaving:'||l_proc, 20);
131 Exception
132 When hr_api.check_integrity_violated Then
133 -- A check constraint has been violated
134 pqh_fyn_shd.constraint_error
135 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
136 When hr_api.parent_integrity_violated Then
137 -- Parent integrity has been violated
138 pqh_fyn_shd.constraint_error
139 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
140 When hr_api.unique_integrity_violated Then
141 -- Unique integrity has been violated
142 pqh_fyn_shd.constraint_error
143 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
144 When Others Then
145 Raise;
146 End insert_dml;
147 --
148 -- ----------------------------------------------------------------------------
149 -- |------------------------------< pre_insert >------------------------------|
150 -- ----------------------------------------------------------------------------
151 -- {Start Of Comments}
152 --
153 -- Description:
154 -- This private procedure contains any processing which is required before
155 -- the insert dml. Presently, if the entity has a corresponding primary
156 -- key which is maintained by an associating sequence, the primary key for
157 -- the entity will be populated with the next sequence value in
158 -- preparation for the insert dml.
159 --
160 -- Prerequisites:
161 -- This is an internal procedure which is called from the ins procedure.
162 --
163 -- In Parameters:
164 -- A Pl/Sql record structre.
165 --
166 -- Post Success:
167 -- Processing continues.
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 pre-processing required before the insert dml is issued should be
175 -- coded within this procedure. As stated above, a good example is the
176 -- generation of a primary key number via a corresponding sequence.
177 -- It is important to note that any 3rd party maintenance should be reviewed
178 -- before placing in this procedure.
179 --
180 -- Access Status:
181 -- Internal Row Handler Use Only.
182 --
183 -- {End Of Comments}
184 -- ----------------------------------------------------------------------------
185 Procedure pre_insert(p_rec in out nocopy pqh_fyn_shd.g_rec_type) is
186 --
187 l_proc varchar2(72) := g_package||'pre_insert';
188 --
189 Cursor C_Sel1 is select pqh_fyi_notify_s.nextval from sys.dual;
190 --
191 Begin
192 hr_utility.set_location('Entering:'||l_proc, 5);
193 --
194 --
195 -- Select the next sequence number
196 --
197 Open C_Sel1;
198 Fetch C_Sel1 Into p_rec.fyi_notified_id;
199 Close C_Sel1;
200 --
201 hr_utility.set_location(' Leaving:'||l_proc, 10);
202 End pre_insert;
203 --
204 -- ----------------------------------------------------------------------------
205 -- |-----------------------------< post_insert >------------------------------|
206 -- ----------------------------------------------------------------------------
207 -- {Start Of Comments}
208 --
209 -- Description:
210 -- This private procedure contains any processing which is required after the
211 -- insert dml.
212 --
213 -- Prerequisites:
214 -- This is an internal procedure which is called from the ins procedure.
215 --
216 -- In Parameters:
217 -- A Pl/Sql record structre.
218 --
219 -- Post Success:
220 -- Processing continues.
221 --
222 -- Post Failure:
223 -- If an error has occurred, an error message and exception will be raised
224 -- but not handled.
225 --
226 -- Developer Implementation Notes:
227 -- Any post-processing required after the insert dml is issued should be
228 -- coded within this procedure. It is important to note that any 3rd party
229 -- maintenance should be reviewed before placing in this procedure.
230 --
231 -- Access Status:
232 -- Internal Row Handler Use Only.
233 --
234 -- {End Of Comments}
235 -- ----------------------------------------------------------------------------
236 Procedure post_insert(
237 p_effective_date in date,p_rec in pqh_fyn_shd.g_rec_type) is
238 --
239 l_proc varchar2(72) := g_package||'post_insert';
240 --
241 Begin
242 hr_utility.set_location('Entering:'||l_proc, 5);
243 --
244 --
245 -- Start of API User Hook for post_insert.
246 --
247 begin
248 --
249 pqh_fyn_rki.after_insert
250 (
251 p_fyi_notified_id =>p_rec.fyi_notified_id
252 ,p_transaction_category_id =>p_rec.transaction_category_id
253 ,p_transaction_id =>p_rec.transaction_id
254 ,p_notification_event_cd =>p_rec.notification_event_cd
255 ,p_notified_type_cd =>p_rec.notified_type_cd
256 ,p_notified_name =>p_rec.notified_name
257 ,p_notification_date =>p_rec.notification_date
258 ,p_status =>p_rec.status
259 ,p_object_version_number =>p_rec.object_version_number
260 ,p_effective_date =>p_effective_date
261 );
262 --
263 exception
264 --
265 when hr_api.cannot_find_prog_unit then
266 --
267 hr_api.cannot_find_prog_unit_error
268 (p_module_name => 'pqh_fyi_notify'
269 ,p_hook_type => 'AI');
270 --
271 end;
272 --
273 -- End of API User Hook for post_insert.
274 --
275 --
276 hr_utility.set_location(' Leaving:'||l_proc, 10);
277 End post_insert;
278 --
279 -- ----------------------------------------------------------------------------
280 -- |---------------------------------< ins >----------------------------------|
281 -- ----------------------------------------------------------------------------
282 Procedure ins
283 (
284 p_effective_date in date,
285 p_rec in out nocopy pqh_fyn_shd.g_rec_type
286 ) is
287 --
288 l_proc varchar2(72) := g_package||'ins';
289 --
290 Begin
291 hr_utility.set_location('Entering:'||l_proc, 5);
292 --
293 -- Call the supporting insert validate operations
294 --
295 pqh_fyn_bus.insert_validate(p_rec
296 ,p_effective_date);
297 --
298 -- Call the supporting pre-insert operation
299 --
300 pre_insert(p_rec);
301 --
302 -- Insert the row
303 --
304 insert_dml(p_rec);
305 --
306 -- Call the supporting post-insert operation
307 --
308 post_insert(
309 p_effective_date,p_rec);
310 end ins;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------------< ins >----------------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure ins
316 (
317 p_effective_date in date,
318 p_fyi_notified_id out nocopy number,
319 p_transaction_category_id in number,
320 p_transaction_id in number,
321 p_notification_event_cd in varchar2,
322 p_notified_type_cd in varchar2 default null,
323 p_notified_name in varchar2 default null,
324 p_notification_date in date default null,
325 p_status in varchar2 default null,
326 p_object_version_number out nocopy number
327 ) is
328 --
329 l_rec pqh_fyn_shd.g_rec_type;
330 l_proc varchar2(72) := g_package||'ins';
331 --
332 Begin
333 hr_utility.set_location('Entering:'||l_proc, 5);
334 --
335 -- Call conversion function to turn arguments into the
336 -- p_rec structure.
337 --
338 l_rec :=
339 pqh_fyn_shd.convert_args
340 (
341 null,
342 p_transaction_category_id,
343 p_transaction_id,
344 p_notification_event_cd,
345 p_notified_type_cd,
346 p_notified_name,
347 p_notification_date,
348 p_status,
349 null
350 );
351 --
352 -- Having converted the arguments into the pqh_fyn_rec
353 -- plsql record structure we call the corresponding record business process.
354 --
355 ins(
356 p_effective_date,l_rec);
357 --
358 -- As the primary key argument(s)
359 -- are specified as an OUT's we must set these values.
360 --
361 p_fyi_notified_id := l_rec.fyi_notified_id;
362 p_object_version_number := l_rec.object_version_number;
363 --
364 hr_utility.set_location(' Leaving:'||l_proc, 10);
365 End ins;
366 --
367 end pqh_fyn_ins;