[Home] [Help]
PACKAGE BODY: APPS.IGI_EXP_TU_TYPE_DETAILS_PKG
Source
1 PACKAGE BODY igi_exp_tu_type_details_pkg AS
2 /* $Header: igiexpvb.pls 120.5.12000000.1 2007/09/13 04:24:59 mbremkum ship $ */
3
4 --following variables added for bug 3199481: fnd logging changes: sdixit
5 l_debug_level number := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
6 l_state_level number := FND_LOG.LEVEL_STATEMENT;
7 l_proc_level number := FND_LOG.LEVEL_PROCEDURE;
8 l_event_level number := FND_LOG.LEVEL_EVENT;
9 l_excep_level number := FND_LOG.LEVEL_EXCEPTION;
10 l_error_level number := FND_LOG.LEVEL_ERROR;
11 l_unexp_level number := FND_LOG.LEVEL_UNEXPECTED;
12
13 l_rowid VARCHAR2(25);
14 old_references igi_exp_tu_type_details_all%ROWTYPE;
15 new_references igi_exp_tu_type_details_all%ROWTYPE;
16
17 PROCEDURE set_column_values (
18 p_action IN VARCHAR2,
19 x_rowid IN VARCHAR2 ,
20 x_tu_type_detail_id IN NUMBER ,
21 x_tu_type_header_id IN NUMBER ,
22 x_du_type_header_id IN NUMBER ,
23 x_org_id IN NUMBER ,
24 x_creation_date IN DATE ,
25 x_created_by IN NUMBER ,
26 x_last_update_date IN DATE ,
27 x_last_updated_by IN NUMBER ,
28 x_last_update_login IN NUMBER ) AS
29 /*
30 || Created By : [email protected]
31 || Created On : 18-OCT-2001
32 || Purpose : Initialises the Old and New references for the columns of the table.
33 || Known limitations, enhancements or remarks :
34 || Change History :
35 || Who When What
36 || (reverse chronological order - newest change first)
37 */
38
39 CURSOR cur_old_ref_values IS
40 SELECT *
41 FROM IGI_EXP_TU_TYPE_DETAILS_ALL
42 WHERE rowid = x_rowid;
43
44 BEGIN
45
46 l_rowid := x_rowid;
47
48 -- Code for setting the Old and New Reference Values.
49 -- Populate Old Values.
50 OPEN cur_old_ref_values;
51 FETCH cur_old_ref_values INTO old_references;
52 IF ((cur_old_ref_values%NOTFOUND) AND (p_action NOT IN ('INSERT', 'VALIDATE_INSERT'))) THEN
53 CLOSE cur_old_ref_values;
54 fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
55 --bug 3199481 fnd logging changes: sdixit: start block
56 IF (l_error_level >= l_debug_level ) THEN
57 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.set_column_values',FALSE);
58 END IF;
59 --bug 3199481 fnd logging changes: sdixit: end block
60
61 app_exception.raise_exception;
62 RETURN;
63 END IF;
64 CLOSE cur_old_ref_values;
65
66 -- Populate New Values.
67 new_references.tu_type_detail_id := x_tu_type_detail_id;
68 new_references.tu_type_header_id := x_tu_type_header_id;
69 new_references.du_type_header_id := x_du_type_header_id;
70 new_references.org_id := x_org_id;
71
72 IF (p_action = 'UPDATE') THEN
73 new_references.creation_date := old_references.creation_date;
74 new_references.created_by := old_references.created_by;
75 ELSE
76 new_references.creation_date := x_creation_date;
77 new_references.created_by := x_created_by;
78 END IF;
79
80 new_references.last_update_date := x_last_update_date;
81 new_references.last_updated_by := x_last_updated_by;
82 new_references.last_update_login := x_last_update_login;
83
84 END set_column_values;
85
86
87 PROCEDURE check_parent_existance AS
88 /*
89 || Created By : [email protected]
90 || Created On : 18-OCT-2001
91 || Purpose : Checks for the existance of Parent records.
92 || Known limitations, enhancements or remarks :
93 || Change History :
94 || Who When What
95 || (reverse chronological order - newest change first)
96 */
97 BEGIN
98
99 IF (((old_references.du_type_header_id = new_references.du_type_header_id)) OR
100 ((new_references.du_type_header_id IS NULL))) THEN
101 NULL;
102 ELSIF NOT igi_exp_du_type_headers_pkg.get_pk_for_validation (
103 new_references.du_type_header_id
104 ) THEN
105 fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
106 --bug 3199481 fnd logging changes: sdixit: start block
107 IF (l_error_level >= l_debug_level ) THEN
108 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.check_parent_existance.msg1',FALSE);
109 END IF;
110 --bug 3199481 fnd logging changes: sdixit: end block
111
112 app_exception.raise_exception;
113 END IF;
114
115 IF (((old_references.tu_type_header_id = new_references.tu_type_header_id)) OR
116 ((new_references.tu_type_header_id IS NULL))) THEN
117 NULL;
118 ELSIF NOT igi_exp_tu_type_headers_pkg.get_pk_for_validation (
119 new_references.tu_type_header_id
120 ) THEN
121 fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
122 --bug 3199481 fnd logging changes: sdixit: start block
123 IF (l_error_level >= l_debug_level ) THEN
124 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.check_parent_existance.msg2',FALSE);
125 END IF;
126 --bug 3199481 fnd logging changes: sdixit: end block
127
128 app_exception.raise_exception;
129 END IF;
130
131 END check_parent_existance;
132
133
134 FUNCTION get_pk_for_validation (
135 x_tu_type_detail_id IN NUMBER
136 ) RETURN BOOLEAN AS
137 /*
138 || Created By : [email protected]
139 || Created On : 18-OCT-2001
140 || Purpose : Validates the Primary Key of the table.
141 || Known limitations, enhancements or remarks :
142 || Change History :
143 || Who When What
144 || (reverse chronological order - newest change first)
145 */
146 CURSOR cur_rowid IS
147 SELECT rowid
148 FROM igi_exp_tu_type_details_all
149 WHERE tu_type_detail_id = x_tu_type_detail_id
150 FOR UPDATE NOWAIT;
151
152 lv_rowid cur_rowid%RowType;
153
154 BEGIN
155
156 OPEN cur_rowid;
157 FETCH cur_rowid INTO lv_rowid;
158 IF (cur_rowid%FOUND) THEN
159 CLOSE cur_rowid;
160 RETURN(TRUE);
161 ELSE
162 CLOSE cur_rowid;
163 RETURN(FALSE);
164 END IF;
165
166 END get_pk_for_validation;
167
168
169 PROCEDURE get_fk_igi_exp_du_type_headers (
170 x_du_type_header_id IN NUMBER
171 ) AS
172 /*
173 || Created By : [email protected]
174 || Created On : 18-OCT-2001
175 || Purpose : Validates the Foreign Keys for the table.
176 || Known limitations, enhancements or remarks :
177 || Change History :
178 || Who When What
179 || (reverse chronological order - newest change first)
180 */
181 CURSOR cur_rowid IS
182 SELECT rowid
183 FROM igi_exp_tu_type_details_all
184 WHERE ((du_type_header_id = x_du_type_header_id));
185
186 lv_rowid cur_rowid%RowType;
187
188 BEGIN
189
190 OPEN cur_rowid;
191 FETCH cur_rowid INTO lv_rowid;
192 IF (cur_rowid%FOUND) THEN
193 CLOSE cur_rowid;
194 fnd_message.set_name ('FND','FND-CANNOT DELETE MASTER');
195 --bug 3199481 fnd logging changes: sdixit: start block
196 IF (l_error_level >= l_debug_level ) THEN
197 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.get_fk_igi_exp_du_type_headers',FALSE);
198 END IF;
199 --bug 3199481 fnd logging changes: sdixit: end block
200
201 app_exception.raise_exception;
202 RETURN;
203 END IF;
204 CLOSE cur_rowid;
205
206 END get_fk_igi_exp_du_type_headers;
207
208
209 PROCEDURE get_fk_igi_exp_tu_type_headers (
210 x_tu_type_header_id IN NUMBER
211 ) AS
212 /*
213 || Created By : [email protected]
214 || Created On : 18-OCT-2001
215 || Purpose : Validates the Foreign Keys for the table.
216 || Known limitations, enhancements or remarks :
217 || Change History :
218 || Who When What
219 || (reverse chronological order - newest change first)
220 */
221 CURSOR cur_rowid IS
222 SELECT rowid
223 FROM igi_exp_tu_type_details_all
224 WHERE ((tu_type_header_id = x_tu_type_header_id));
225
226 lv_rowid cur_rowid%RowType;
227
228 BEGIN
229
230 OPEN cur_rowid;
231 FETCH cur_rowid INTO lv_rowid;
232 IF (cur_rowid%FOUND) THEN
233 CLOSE cur_rowid;
234 fnd_message.set_name ('FND','FND-CANNOT DELETE MASTER');
235 --bug 3199481 fnd logging changes: sdixit: start block
236 IF (l_error_level >= l_debug_level ) THEN
237 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.get_fk_igi_exp_du_type_headers',FALSE);
238 END IF;
239 --bug 3199481 fnd logging changes: sdixit: end block
240
241 app_exception.raise_exception;
242 RETURN;
243 END IF;
244 CLOSE cur_rowid;
245
246 END get_fk_igi_exp_tu_type_headers;
247
248
249 PROCEDURE before_dml (
250 p_action IN VARCHAR2,
251 x_rowid IN VARCHAR2 ,
252 x_tu_type_detail_id IN NUMBER ,
253 x_tu_type_header_id IN NUMBER ,
254 x_du_type_header_id IN NUMBER ,
255 x_org_id IN NUMBER ,
256 x_creation_date IN DATE ,
257 x_created_by IN NUMBER ,
258 x_last_update_date IN DATE ,
259 x_last_updated_by IN NUMBER ,
260 x_last_update_login IN NUMBER ) AS
261 /*
262 || Created By : [email protected]
263 || Created On : 18-OCT-2001
264 || Purpose : Initialises the columns, Checks Constraints, Calls the
265 || Trigger Handlers for the table, before any DML operation.
266 || Known limitations, enhancements or remarks :
267 || Change History :
268 || Who When What
269 || (reverse chronological order - newest change first)
270 */
271 BEGIN
272
273 set_column_values (
274 p_action,
275 x_rowid,
276 x_tu_type_detail_id,
277 x_tu_type_header_id,
278 x_du_type_header_id,
279 x_org_id,
280 x_creation_date,
281 x_created_by,
282 x_last_update_date,
283 x_last_updated_by,
284 x_last_update_login
285 );
286
287 IF (p_action = 'INSERT') THEN
288 -- Call all the procedures related to Before Insert.
289 IF ( get_pk_for_validation(
290 new_references.tu_type_detail_id
291 )
292 ) THEN
293 fnd_message.set_name('IGI','IGI_EXP_DUP_ROW');
294 --bug 3199481 fnd logging changes: sdixit: start block
295 IF (l_error_level >= l_debug_level ) THEN
296 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.before_dml',FALSE);
297 END IF;
298 --bug 3199481 fnd logging changes: sdixit: end block
299
300 app_exception.raise_exception;
301 END IF;
302 check_parent_existance;
303 ELSIF (p_action = 'UPDATE') THEN
304 -- Call all the procedures related to Before Update.
305 check_parent_existance;
306 ELSIF (p_action = 'VALIDATE_INSERT') THEN
307 -- Call all the procedures related to Before Insert.
308 IF ( get_pk_for_validation (
309 new_references.tu_type_detail_id
310 )
311 ) THEN
312 fnd_message.set_name('IGI','IGI_EXP_DUP_ROW');
313 --bug 3199481 fnd logging changes: sdixit: start block
314 IF (l_error_level >= l_debug_level ) THEN
315 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.before_dml',FALSE);
316 END IF;
317 --bug 3199481 fnd logging changes: sdixit: end block
318
319 app_exception.raise_exception;
320 END IF;
321 END IF;
322
323 END before_dml;
324
325
326 PROCEDURE insert_row (
327 x_rowid IN OUT NOCOPY VARCHAR2,
328 x_tu_type_detail_id IN OUT NOCOPY NUMBER,
329 x_tu_type_header_id IN NUMBER,
330 x_du_type_header_id IN NUMBER,
331 x_org_id IN NUMBER,
332 x_mode IN VARCHAR2 ) AS
333 /*
334 || Created By : [email protected]
335 || Created On : 18-OCT-2001
336 || Purpose : Handles the INSERT DML logic for the table.
337 || Known limitations, enhancements or remarks :
338 || Change History :
339 || Who When What
340 || (reverse chronological order - newest change first)
341 */
342 CURSOR c IS
343 SELECT rowid
344 FROM igi_exp_tu_type_details_all
345 WHERE tu_type_detail_id = x_tu_type_detail_id;
346
347 x_last_update_date DATE;
348 x_last_updated_by NUMBER;
349 x_last_update_login NUMBER;
350
351 BEGIN
352
353 x_last_update_date := SYSDATE;
354 IF (x_mode = 'I') THEN
355 x_last_updated_by := 1;
356 x_last_update_login := 0;
357 ELSIF (x_mode = 'R') THEN
358 x_last_updated_by := fnd_global.user_id;
359 IF (x_last_updated_by IS NULL) THEN
360 x_last_updated_by := -1;
361 END IF;
362 x_last_update_login := fnd_global.login_id;
363 IF (x_last_update_login IS NULL) THEN
364 x_last_update_login := -1;
365 END IF;
366 ELSE
367 fnd_message.set_name ('FND', 'SYSTEM-INVALID ARGS');
368 --bug 3199481 fnd logging changes: sdixit: start block
369 IF (l_error_level >= l_debug_level ) THEN
370 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.insert_row',FALSE);
371 END IF;
372 --bug 3199481 fnd logging changes: sdixit: end block
373
377 SELECT igi_exp_tu_type_details_s1.NEXTVAL
374 app_exception.raise_exception;
375 END IF;
376
378 INTO x_tu_type_detail_id
379 FROM dual;
380
381 before_dml(
382 p_action => 'INSERT',
383 x_rowid => x_rowid,
384 x_tu_type_detail_id => x_tu_type_detail_id,
385 x_tu_type_header_id => x_tu_type_header_id,
386 x_du_type_header_id => x_du_type_header_id,
387 x_org_id => x_org_id,
388 x_creation_date => x_last_update_date,
389 x_created_by => x_last_updated_by,
390 x_last_update_date => x_last_update_date,
391 x_last_updated_by => x_last_updated_by,
392 x_last_update_login => x_last_update_login
393 );
394
395 INSERT INTO igi_exp_tu_type_details_all (
396 tu_type_detail_id,
397 tu_type_header_id,
398 du_type_header_id,
399 org_id,
400 creation_date,
401 created_by,
402 last_update_date,
403 last_updated_by,
404 last_update_login
405 ) VALUES (
406 new_references.tu_type_detail_id,
407 new_references.tu_type_header_id,
408 new_references.du_type_header_id,
409 new_references.org_id,
410 x_last_update_date,
411 x_last_updated_by,
412 x_last_update_date,
413 x_last_updated_by,
414 x_last_update_login
415 );
416
417 OPEN c;
418 FETCH c INTO x_rowid;
419 IF (c%NOTFOUND) THEN
420 CLOSE c;
421 RAISE NO_DATA_FOUND;
422 END IF;
423 CLOSE c;
424
425 END insert_row;
426
427
428 PROCEDURE lock_row (
429 x_rowid IN VARCHAR2,
430 x_tu_type_detail_id IN NUMBER,
431 x_tu_type_header_id IN NUMBER,
432 x_du_type_header_id IN NUMBER,
433 x_org_id IN NUMBER
434 ) AS
435 /*
436 || Created By : [email protected]
437 || Created On : 18-OCT-2001
438 || Purpose : Handles the LOCK mechanism for the table.
439 || Known limitations, enhancements or remarks :
440 || Change History :
441 || Who When What
442 || (reverse chronological order - newest change first)
443 */
444 CURSOR c1 IS
445 SELECT
446 tu_type_header_id,
447 du_type_header_id,
448 org_id
449 FROM igi_exp_tu_type_details_all
450 WHERE rowid = x_rowid
451 FOR UPDATE NOWAIT;
452
453 tlinfo c1%ROWTYPE;
454
455 BEGIN
456
457 OPEN c1;
458 FETCH c1 INTO tlinfo;
459 IF (c1%notfound) THEN
460 fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
461 --bug 3199481 fnd logging changes: sdixit: start block
462 IF (l_error_level >= l_debug_level ) THEN
463 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.lock_row.msg1',FALSE);
464 END IF;
465 --bug 3199481 fnd logging changes: sdixit: end block
466
467 CLOSE c1;
468 app_exception.raise_exception;
469 RETURN;
470 END IF;
471 CLOSE c1;
472
473 IF (
474 (tlinfo.tu_type_header_id = x_tu_type_header_id)
475 AND (tlinfo.du_type_header_id = x_du_type_header_id)
476 AND (tlinfo.org_id = x_org_id)
477 ) THEN
478 NULL;
479 ELSE
480 fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
481 --bug 3199481 fnd logging changes: sdixit: start block
482 IF (l_error_level >= l_debug_level ) THEN
483 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.lock_row.msg2',FALSE);
484 END IF;
485 --bug 3199481 fnd logging changes: sdixit: end block
486
487 app_exception.raise_exception;
488 END IF;
489
490 RETURN;
491
492 END lock_row;
493
494
495 PROCEDURE update_row (
496 x_rowid IN VARCHAR2,
497 x_tu_type_detail_id IN NUMBER,
498 x_tu_type_header_id IN NUMBER,
499 x_du_type_header_id IN NUMBER,
500 x_org_id IN NUMBER,
501 x_mode IN VARCHAR2 ) AS
502 /*
503 || Created By : [email protected]
504 || Created On : 18-OCT-2001
505 || Purpose : Handles the UPDATE DML logic for the table.
506 || Known limitations, enhancements or remarks :
507 || Change History :
508 || Who When What
509 || (reverse chronological order - newest change first)
510 */
511 x_last_update_date DATE ;
512 x_last_updated_by NUMBER;
513 x_last_update_login NUMBER;
514
515 BEGIN
516
517 x_last_update_date := SYSDATE;
518 IF (X_MODE = 'I') THEN
519 x_last_updated_by := 1;
520 x_last_update_login := 0;
524 x_last_updated_by := -1;
521 ELSIF (x_mode = 'R') THEN
522 x_last_updated_by := fnd_global.user_id;
523 IF x_last_updated_by IS NULL THEN
525 END IF;
526 x_last_update_login := fnd_global.login_id;
527 IF (x_last_update_login IS NULL) THEN
528 x_last_update_login := -1;
529 END IF;
530 ELSE
531 fnd_message.set_name( 'FND', 'SYSTEM-INVALID ARGS');
532 --bug 3199481 fnd logging changes: sdixit: start block
533 IF (l_error_level >= l_debug_level ) THEN
534 FND_LOG.MESSAGE (l_error_level , 'igi.plsql.igiexpvb.IGI_EXP_TU_TYPE_DETAILS_PKG.update_row',FALSE);
535 END IF;
536 --bug 3199481 fnd logging changes: sdixit: end block
537
538 app_exception.raise_exception;
539 END IF;
540
541 before_dml(
542 p_action => 'UPDATE',
543 x_rowid => x_rowid,
544 x_tu_type_detail_id => x_tu_type_detail_id,
545 x_tu_type_header_id => x_tu_type_header_id,
546 x_du_type_header_id => x_du_type_header_id,
547 x_org_id => x_org_id,
548 x_creation_date => x_last_update_date,
549 x_created_by => x_last_updated_by,
550 x_last_update_date => x_last_update_date,
551 x_last_updated_by => x_last_updated_by,
552 x_last_update_login => x_last_update_login
553 );
554
555 UPDATE igi_exp_tu_type_details_all
556 SET
557 tu_type_header_id = new_references.tu_type_header_id,
558 du_type_header_id = new_references.du_type_header_id,
559 org_id = new_references.org_id,
560 last_update_date = x_last_update_date,
561 last_updated_by = x_last_updated_by,
562 last_update_login = x_last_update_login
563 WHERE rowid = x_rowid;
564
565 IF (SQL%NOTFOUND) THEN
566 RAISE NO_DATA_FOUND;
567 END IF;
568
569 END update_row;
570
571
572 PROCEDURE add_row (
573 x_rowid IN OUT NOCOPY VARCHAR2,
574 x_tu_type_detail_id IN OUT NOCOPY NUMBER,
575 x_tu_type_header_id IN NUMBER,
576 x_du_type_header_id IN NUMBER,
577 x_org_id IN NUMBER,
578 x_mode IN VARCHAR2 ) AS
579 /*
580 || Created By : [email protected]
581 || Created On : 18-OCT-2001
582 || Purpose : Adds a row if there is no existing row, otherwise updates existing row in the table.
583 || Known limitations, enhancements or remarks :
584 || Change History :
585 || Who When What
586 || (reverse chronological order - newest change first)
587 */
588 CURSOR c1 IS
589 SELECT rowid
590 FROM igi_exp_tu_type_details_all
591 WHERE tu_type_detail_id = x_tu_type_detail_id;
592
593 BEGIN
594
595 OPEN c1;
596 FETCH c1 INTO x_rowid;
597 IF (c1%NOTFOUND) THEN
598 CLOSE c1;
599
600 insert_row (
601 x_rowid,
602 x_tu_type_detail_id,
603 x_tu_type_header_id,
604 x_du_type_header_id,
605 x_org_id,
606 x_mode
607 );
608 RETURN;
609 END IF;
610 CLOSE c1;
611
612 update_row (
613 x_rowid,
614 x_tu_type_detail_id,
615 x_tu_type_header_id,
616 x_du_type_header_id,
617 x_org_id,
618 x_mode
619 );
620
621 END add_row;
622
623
624 PROCEDURE delete_row (
625 x_rowid IN VARCHAR2
626 ) AS
627 /*
628 || Created By : [email protected]
629 || Created On : 18-OCT-2001
630 || Purpose : Handles the DELETE DML logic for the table.
631 || Known limitations, enhancements or remarks :
632 || Change History :
633 || Who When What
634 || (reverse chronological order - newest change first)
635 */
636 BEGIN
637
638 before_dml (
639 p_action => 'DELETE',
640 x_rowid => x_rowid
641 );
642
643 DELETE FROM igi_exp_tu_type_details_all
644 WHERE rowid = x_rowid;
645
646 IF (SQL%NOTFOUND) THEN
647 RAISE NO_DATA_FOUND;
648 END IF;
649
650 END delete_row;
651
652
653 END igi_exp_tu_type_details_pkg;