[Home] [Help]
PACKAGE BODY: APPS.IGS_AD_CRT_APPL_CFG_PKG
Source
1 PACKAGE BODY igs_ad_crt_appl_cfg_pkg AS
2 /* $Header: IGSAIH6B.pls 120.1 2005/09/08 15:13:33 appldev noship $ */
3
4 l_rowid VARCHAR2(25);
5 old_references igs_ad_crt_appl_cfg%ROWTYPE;
6 new_references igs_ad_crt_appl_cfg%ROWTYPE;
7
8 PROCEDURE set_column_values (
9 p_action IN VARCHAR2,
10 x_rowid IN VARCHAR2,
11 x_responsibility IN VARCHAR2,
12 x_component_code IN VARCHAR2,
13 x_display_name IN VARCHAR2,
14 x_included_flag IN VARCHAR2,
15 x_required_flag IN VARCHAR2,
16 x_creation_date IN DATE,
17 x_created_by IN NUMBER,
18 x_last_update_date IN DATE,
19 x_last_updated_by IN NUMBER,
20 x_last_update_login IN NUMBER
21 ) AS
22 /*
23 || Created By : [email protected]
24 || Created On : 15-JUL-2005
25 || Purpose : Initialises the Old and New references for the columns of the table.
26 || Known limitations, enhancements or remarks :
27 || Change History :
28 || Who When What
29 || (reverse chronological order - newest change first)
30 */
31
32 CURSOR cur_old_ref_values IS
33 SELECT *
34 FROM igs_ad_crt_appl_cfg
35 WHERE rowid = x_rowid;
36
37 BEGIN
38
39 l_rowid := x_rowid;
40
41 -- Code for setting the Old and New Reference Values.
42 -- Populate Old Values.
43 OPEN cur_old_ref_values;
44 FETCH cur_old_ref_values INTO old_references;
45 IF ((cur_old_ref_values%NOTFOUND) AND (p_action NOT IN ('INSERT', 'VALIDATE_INSERT'))) THEN
46 CLOSE cur_old_ref_values;
47 fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
48 igs_ge_msg_stack.add;
49 app_exception.raise_exception;
50 RETURN;
51 END IF;
52 CLOSE cur_old_ref_values;
53
54 -- Populate New Values.
55 new_references.responsibility := x_responsibility;
56 new_references.component_code := x_component_code;
57 new_references.display_name := x_display_name;
58 new_references.included_flag := x_included_flag;
59 new_references.required_flag := x_required_flag;
60
61 IF (p_action = 'UPDATE') THEN
62 new_references.creation_date := old_references.creation_date;
63 new_references.created_by := old_references.created_by;
64 ELSE
65 new_references.creation_date := x_creation_date;
66 new_references.created_by := x_created_by;
67 END IF;
68
69 new_references.last_update_date := x_last_update_date;
70 new_references.last_updated_by := x_last_updated_by;
71 new_references.last_update_login := x_last_update_login;
72
73 END set_column_values;
74
75
76 FUNCTION get_pk_for_validation (
77 x_responsibility IN VARCHAR2,
78 x_component_code IN VARCHAR2
79 ) RETURN BOOLEAN AS
80 /*
81 || Created By : [email protected]
82 || Created On : 15-JUL-2005
83 || Purpose : Validates the Primary Key of the table.
84 || Known limitations, enhancements or remarks :
85 || Change History :
86 || Who When What
87 || (reverse chronological order - newest change first)
88 */
89 CURSOR cur_rowid IS
90 SELECT rowid
91 FROM igs_ad_crt_appl_cfg
92 WHERE responsibility = x_responsibility
93 AND component_code = x_component_code
94 FOR UPDATE NOWAIT;
95
96 lv_rowid cur_rowid%RowType;
97
98 BEGIN
99
100 OPEN cur_rowid;
101 FETCH cur_rowid INTO lv_rowid;
102 IF (cur_rowid%FOUND) THEN
103 CLOSE cur_rowid;
104 RETURN(TRUE);
105 ELSE
106 CLOSE cur_rowid;
107 RETURN(FALSE);
108 END IF;
109
110 END get_pk_for_validation;
111
112
113 PROCEDURE before_dml (
114 p_action IN VARCHAR2,
115 x_rowid IN VARCHAR2,
116 x_responsibility IN VARCHAR2,
117 x_component_code IN VARCHAR2,
118 x_display_name IN VARCHAR2,
119 x_included_flag IN VARCHAR2,
120 x_required_flag IN VARCHAR2,
121 x_creation_date IN DATE,
122 x_created_by IN NUMBER,
123 x_last_update_date IN DATE,
124 x_last_updated_by IN NUMBER,
125 x_last_update_login IN NUMBER
126 ) AS
127 /*
128 || Created By : [email protected]
129 || Created On : 15-JUL-2005
130 || Purpose : Initialises the columns, Checks Constraints, Calls the
131 || Trigger Handlers for the table, before any DML operation.
132 || Known limitations, enhancements or remarks :
133 || Change History :
134 || Who When What
135 || (reverse chronological order - newest change first)
136 */
137 BEGIN
138
139 set_column_values (
140 p_action,
141 x_rowid,
142 x_responsibility,
143 x_component_code,
144 x_display_name,
145 x_included_flag,
146 x_required_flag,
147 x_creation_date,
148 x_created_by,
149 x_last_update_date,
150 x_last_updated_by,
151 x_last_update_login
152 );
153
154 IF (p_action = 'INSERT') THEN
155 -- Call all the procedures related to Before Insert.
156 IF ( get_pk_for_validation(
157 new_references.responsibility,
158 new_references.component_code
159 )
160 ) THEN
161 fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
162 igs_ge_msg_stack.add;
163 app_exception.raise_exception;
164 END IF;
165 ELSIF (p_action = 'VALIDATE_INSERT') THEN
166 -- Call all the procedures related to Before Insert.
167 IF ( get_pk_for_validation (
168 new_references.responsibility,
169 new_references.component_code
170 )
171 ) THEN
172 fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
173 igs_ge_msg_stack.add;
174 app_exception.raise_exception;
175 END IF;
176 END IF;
177
178 END before_dml;
179
180
181 PROCEDURE insert_row (
182 x_rowid IN OUT NOCOPY VARCHAR2,
183 x_responsibility IN VARCHAR2,
184 x_component_code IN OUT NOCOPY VARCHAR2,
185 x_display_name IN VARCHAR2,
186 x_included_flag IN VARCHAR2,
187 x_required_flag IN VARCHAR2,
188 x_mode IN VARCHAR2
189 ) AS
190 /*
191 || Created By : [email protected]
192 || Created On : 15-JUL-2005
193 || Purpose : Handles the INSERT DML logic for the table.
194 || Known limitations, enhancements or remarks :
195 || Change History :
196 || Who When What
197 || (reverse chronological order - newest change first)
198 */
199
200 x_last_update_date DATE;
201 x_last_updated_by NUMBER;
202 x_last_update_login NUMBER;
203
204 BEGIN
205
206 x_last_update_date := SYSDATE;
207 IF (x_mode = 'I') THEN
208 x_last_updated_by := 1;
209 x_last_update_login := 0;
210 ELSIF (x_mode = 'R') THEN
211 x_last_updated_by := fnd_global.user_id;
212 IF (x_last_updated_by IS NULL) THEN
213 x_last_updated_by := -1;
214 END IF;
215 x_last_update_login := fnd_global.login_id;
216 IF (x_last_update_login IS NULL) THEN
217 x_last_update_login := -1;
218 END IF;
219 ELSE
220 fnd_message.set_name ('FND', 'SYSTEM-INVALID ARGS');
221 fnd_message.set_token ('ROUTINE', 'IGS_AD_CRT_APPL_CFG_PKG.INSERT_ROW');
222 igs_ge_msg_stack.add;
223 app_exception.raise_exception;
224 END IF;
225
226 x_component_code := NULL;
227
228 before_dml(
229 p_action => 'INSERT',
230 x_rowid => x_rowid,
231 x_responsibility => x_responsibility,
232 x_component_code => x_component_code,
233 x_display_name => x_display_name,
234 x_included_flag => x_included_flag,
235 x_required_flag => x_required_flag,
236 x_creation_date => x_last_update_date,
237 x_created_by => x_last_updated_by,
238 x_last_update_date => x_last_update_date,
239 x_last_updated_by => x_last_updated_by,
240 x_last_update_login => x_last_update_login
241 );
242
243 INSERT INTO igs_ad_crt_appl_cfg (
244 responsibility,
245 component_code,
246 display_name,
247 included_flag,
248 required_flag,
249 creation_date,
250 created_by,
251 last_update_date,
252 last_updated_by,
253 last_update_login
254 ) VALUES (
255 new_references.responsibility,
256 new_references.component_code,
257 new_references.display_name,
258 new_references.included_flag,
259 new_references.required_flag,
260 x_last_update_date,
261 x_last_updated_by,
262 x_last_update_date,
263 x_last_updated_by,
264 x_last_update_login
265 ) RETURNING ROWID, component_code INTO x_rowid, x_component_code;
266
267 END insert_row;
268
269
270 PROCEDURE lock_row (
271 x_rowid IN VARCHAR2,
272 x_responsibility IN VARCHAR2,
273 x_component_code IN VARCHAR2,
274 x_display_name IN VARCHAR2,
275 x_included_flag IN VARCHAR2,
276 x_required_flag IN VARCHAR2
277 ) AS
278 /*
279 || Created By : [email protected]
280 || Created On : 15-JUL-2005
281 || Purpose : Handles the LOCK mechanism for the table.
282 || Known limitations, enhancements or remarks :
283 || Change History :
284 || Who When What
285 || (reverse chronological order - newest change first)
286 */
287 CURSOR c1 IS
288 SELECT
289 display_name,
290 included_flag,
291 required_flag
292 FROM igs_ad_crt_appl_cfg
293 WHERE rowid = x_rowid
294 FOR UPDATE NOWAIT;
295
296 tlinfo c1%ROWTYPE;
297
298 BEGIN
299
300 OPEN c1;
301 FETCH c1 INTO tlinfo;
302 IF (c1%notfound) THEN
303 fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
304 igs_ge_msg_stack.add;
305 CLOSE c1;
306 app_exception.raise_exception;
307 RETURN;
308 END IF;
309 CLOSE c1;
310
311 IF (
312 (tlinfo.display_name = x_display_name)
313 AND (tlinfo.included_flag = x_included_flag)
314 AND (tlinfo.required_flag = x_required_flag)
315 ) THEN
316 NULL;
317 ELSE
318 fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
319 igs_ge_msg_stack.add;
320 app_exception.raise_exception;
321 END IF;
322
323 RETURN;
324
325 END lock_row;
326
327
328 PROCEDURE update_row (
329 x_rowid IN VARCHAR2,
330 x_responsibility IN VARCHAR2,
331 x_component_code IN VARCHAR2,
332 x_display_name IN VARCHAR2,
333 x_included_flag IN VARCHAR2,
334 x_required_flag IN VARCHAR2,
335 x_mode IN VARCHAR2
336 ) AS
337 /*
338 || Created By : [email protected]
339 || Created On : 15-JUL-2005
340 || Purpose : Handles the UPDATE DML logic for the table.
341 || Known limitations, enhancements or remarks :
342 || Change History :
343 || Who When What
344 || (reverse chronological order - newest change first)
345 */
346 x_last_update_date DATE ;
347 x_last_updated_by NUMBER;
348 x_last_update_login NUMBER;
349
350 BEGIN
351
352 x_last_update_date := SYSDATE;
353 IF (X_MODE = 'I') THEN
354 x_last_updated_by := 1;
355 x_last_update_login := 0;
356 ELSIF (x_mode = 'R') THEN
357 x_last_updated_by := fnd_global.user_id;
358 IF x_last_updated_by IS NULL THEN
359 x_last_updated_by := -1;
360 END IF;
361 x_last_update_login := fnd_global.login_id;
362 IF (x_last_update_login IS NULL) THEN
363 x_last_update_login := -1;
364 END IF;
365 ELSE
366 fnd_message.set_name( 'FND', 'SYSTEM-INVALID ARGS');
367 fnd_message.set_token ('ROUTINE', 'IGS_AD_CRT_APPL_CFG_PKG.UPDATE_ROW');
368 igs_ge_msg_stack.add;
369 app_exception.raise_exception;
370 END IF;
371
372 before_dml(
373 p_action => 'UPDATE',
374 x_rowid => x_rowid,
375 x_responsibility => x_responsibility,
376 x_component_code => x_component_code,
377 x_display_name => x_display_name,
378 x_included_flag => x_included_flag,
379 x_required_flag => x_required_flag,
380 x_creation_date => x_last_update_date,
381 x_created_by => x_last_updated_by,
382 x_last_update_date => x_last_update_date,
383 x_last_updated_by => x_last_updated_by,
384 x_last_update_login => x_last_update_login
385 );
386
387 UPDATE igs_ad_crt_appl_cfg
388 SET
389 display_name = new_references.display_name,
390 included_flag = new_references.included_flag,
391 required_flag = new_references.required_flag,
392 last_update_date = x_last_update_date,
393 last_updated_by = x_last_updated_by,
394 last_update_login = x_last_update_login
395 WHERE rowid = x_rowid;
396
397 IF (SQL%NOTFOUND) THEN
398 RAISE NO_DATA_FOUND;
399 END IF;
400
401 END update_row;
402
403
404 PROCEDURE add_row (
405 x_rowid IN OUT NOCOPY VARCHAR2,
406 x_responsibility IN VARCHAR2,
407 x_component_code IN OUT NOCOPY VARCHAR2,
408 x_display_name IN VARCHAR2,
409 x_included_flag IN VARCHAR2,
410 x_required_flag IN VARCHAR2,
411 x_mode IN VARCHAR2
412 ) AS
413 /*
414 || Created By : [email protected]
415 || Created On : 15-JUL-2005
416 || Purpose : Adds a row if there is no existing row, otherwise updates existing row in the table.
417 || Known limitations, enhancements or remarks :
418 || Change History :
419 || Who When What
420 || (reverse chronological order - newest change first)
421 */
422 CURSOR c1 IS
423 SELECT rowid
424 FROM igs_ad_crt_appl_cfg
425 WHERE responsibility = x_responsibility
426 AND component_code = x_component_code;
427
428 BEGIN
429
430 OPEN c1;
431 FETCH c1 INTO x_rowid;
432 IF (c1%NOTFOUND) THEN
433 CLOSE c1;
434
435 insert_row (
436 x_rowid,
437 x_responsibility,
438 x_component_code,
439 x_display_name,
440 x_included_flag,
441 x_required_flag,
442 x_mode
443 );
444 RETURN;
445 END IF;
446 CLOSE c1;
447
448 update_row (
449 x_rowid,
450 x_responsibility,
451 x_component_code,
452 x_display_name,
453 x_included_flag,
454 x_required_flag,
455 x_mode
456 );
457
458 END add_row;
459
460
461 PROCEDURE delete_row (
462 x_rowid IN VARCHAR2
463 ) AS
464 /*
465 || Created By : [email protected]
466 || Created On : 15-JUL-2005
467 || Purpose : Handles the DELETE DML logic for the table.
468 || Known limitations, enhancements or remarks :
469 || Change History :
470 || Who When What
471 || (reverse chronological order - newest change first)
472 */
473 BEGIN
474
475 before_dml (
476 p_action => 'DELETE',
477 x_rowid => x_rowid
478 );
479
480 DELETE FROM igs_ad_crt_appl_cfg
481 WHERE rowid = x_rowid;
482
483 IF (SQL%NOTFOUND) THEN
484 RAISE NO_DATA_FOUND;
485 END IF;
486
487 END delete_row;
488
489
490 END igs_ad_crt_appl_cfg_pkg;