DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGS_CO_MAPPING_PKG

Source


1 PACKAGE BODY igs_co_mapping_pkg AS
2 /* $Header: IGSLI29B.pls 120.0 2005/06/01 23:37:26 appldev noship $ */
3 
4   l_rowid VARCHAR2(25);
5   old_references igs_co_mapping%ROWTYPE;
6   new_references igs_co_mapping%ROWTYPE;
7 
8   PROCEDURE set_column_values (
9     p_action                            IN     VARCHAR2,
10     x_rowid                             IN     VARCHAR2    DEFAULT NULL,
11     x_map_id                            IN     NUMBER      DEFAULT NULL,
12     x_map_code                          IN     VARCHAR2    DEFAULT NULL,
13     x_doc_code                          IN     VARCHAR2    DEFAULT NULL,
14     x_document_id                       IN     NUMBER      DEFAULT NULL,
15     x_enable_flag                       IN     VARCHAR2    DEFAULT NULL,
16     x_sys_ltr_code                      IN     VARCHAR2    DEFAULT NULL,
17     x_map_description                   IN     VARCHAR2    DEFAULT NULL,
18     x_elapsed_days                      IN     NUMBER      DEFAULT NULL,
19     x_repeat_times                      IN     NUMBER      DEFAULT NULL,
20     x_attr_description                  IN     VARCHAR2    DEFAULT NULL,
21     x_creation_date                     IN     DATE        DEFAULT NULL,
22     x_created_by                        IN     NUMBER      DEFAULT NULL,
23     x_last_update_date                  IN     DATE        DEFAULT NULL,
24     x_last_updated_by                   IN     NUMBER      DEFAULT NULL,
25     x_last_update_login                 IN     NUMBER      DEFAULT NULL
26   ) AS
27   /*
28   ||  Created By : prchandr
29   ||  Created On : 07-FEB-2002
30   ||  Purpose : Initialises the Old and New references for the columns of the table.
31   ||  Known limitations, enhancements or remarks :
32   ||  Change History :
33   ||  Who             When            What
34   ||  (reverse chronological order - newest change first)
35   */
36 
37     CURSOR cur_old_ref_values IS
38       SELECT   *
39       FROM     igs_co_mapping
40       WHERE    rowid = x_rowid;
41 
42   BEGIN
43 
44     l_rowid := x_rowid;
45 
46     -- Code for setting the Old and New Reference Values.
47     -- Populate Old Values.
48     OPEN cur_old_ref_values;
49     FETCH cur_old_ref_values INTO old_references;
50     IF ((cur_old_ref_values%NOTFOUND) AND (p_action NOT IN ('INSERT', 'VALIDATE_INSERT'))) THEN
51       CLOSE cur_old_ref_values;
52       fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
53       igs_ge_msg_stack.add;
54       app_exception.raise_exception;
55       RETURN;
56     END IF;
57     CLOSE cur_old_ref_values;
58 
59     -- Populate New Values.
60     new_references.map_id                            := x_map_id;
61     new_references.map_code                          := x_map_code;
62     new_references.doc_code                          := x_doc_code;
63     new_references.document_id                       := x_document_id;
64     new_references.enable_flag                       := x_enable_flag;
65     new_references.sys_ltr_code                      := x_sys_ltr_code;
66     new_references.map_description                   := x_map_description;
67     new_references.elapsed_days                      := x_elapsed_days;
68     new_references.repeat_times                      := x_repeat_times;
69     new_references.attr_description                  := x_attr_description;
70 
71     IF (p_action = 'UPDATE') THEN
72       new_references.creation_date                   := old_references.creation_date;
73       new_references.created_by                      := old_references.created_by;
74     ELSE
75       new_references.creation_date                   := x_creation_date;
76       new_references.created_by                      := x_created_by;
77     END IF;
78 
79     new_references.last_update_date                  := x_last_update_date;
80     new_references.last_updated_by                   := x_last_updated_by;
81     new_references.last_update_login                 := x_last_update_login;
82 
83   END set_column_values;
84 
85 
86   PROCEDURE check_uniqueness AS
87   /*
88   ||  Created By : prchandr
89   ||  Created On : 07-FEB-2002
90   ||  Purpose : Handles the Unique Constraint logic defined for the columns.
91   ||  Known limitations, enhancements or remarks :
92   ||  Change History :
93   ||  Who             When            What
94   ||  (reverse chronological order - newest change first)
95   */
96   BEGIN
97 
98     IF ( get_uk_for_validation (
99            new_references.document_id,
100            new_references.map_code,
101            new_references.sys_ltr_code
102          )
103        ) THEN
104      IF new_references.enable_flag='Y' THEN
105       fnd_message.set_name ('IGS', 'IGS_GE_RECORD_ALREADY_EXISTS');
106       igs_ge_msg_stack.add;
107       app_exception.raise_exception;
108     END IF;
109     END IF;
110 
111   END check_uniqueness;
112 
113 
114   PROCEDURE check_parent_existance AS
115   /*
116   ||  Created By : prchandr
117   ||  Created On : 07-FEB-2002
118   ||  Purpose : Checks for the existance of Parent records.
119   ||  Known limitations, enhancements or remarks :
120   ||  Change History :
121   ||  Who             When            What
122   ||  kumma           07-JUN-2003     Modified the cursor to use the new data modal
123   ||  ssawhney        4-may-2004      IBC.C patchset changes bug 3565861, different cursors for LIST and DOCUMENT
124   */
125 
126 
127   CURSOR c_list_item (cp_id IN NUMBER, cp_ctype_code IN VARCHAR) IS
128           SELECT COUNT(citem_id)
129 	  FROM IBC_CITEMS_V
130 	  WHERE CITEM_ID = cp_id AND
131 	  CTYPE_CODE =cp_ctype_code AND
132 	  LANGUAGE = USERENV('LANG');
133 
134 
135   CURSOR c_doc_item (cp_id IN NUMBER) IS
136           SELECT COUNT(content_item_id)
137 	  FROM IBC_CONTENT_ITEMS
138 	  WHERE CONTENT_ITEM_ID = cp_id AND
139 	  EXISTS
140 	  (SELECT CONTENT_TYPE_CODE FROM IBC_CTYPE_GROUP_NODES WHERE
141 	   DIRECTORY_NODE_ID IN (32,33,34));
142 
143   l_list_item NUMBER;
144   l_doc_item NUMBER;
145 
146   BEGIN
147 
148 
149   IF new_references.map_code='LIST' THEN
150     OPEN c_list_item (new_references.document_id,'IBC_QUERY');
151     FETCH c_list_item INTO l_list_item;
152     CLOSE c_list_item;
153 
154      IF (((old_references.document_id = new_references.document_id)) OR
155         ((new_references.document_id IS NULL))) THEN
156        NULL;
157      ELSIF l_list_item = 0 THEN
158        fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
159        igs_ge_msg_stack.add;
160        app_exception.raise_exception;
161      END IF;
162    ELSIF new_references.map_code = 'DOCUMENT' THEN
163      OPEN c_doc_item(new_references.document_id);
164      FETCH c_doc_item INTO l_doc_item;
165      CLOSE c_doc_item;
166 
167      IF (((old_references.document_id = new_references.document_id)) OR
168         ((new_references.document_id IS NULL))) THEN
169        NULL;
170      ELSIF l_doc_item = 0 THEN
171        fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
172        igs_ge_msg_stack.add;
173        app_exception.raise_exception;
174      END IF;
175    END IF;
176 
177   END check_parent_existance;
178 
179 
180   FUNCTION get_pk_for_validation (
181     x_map_id                            IN     NUMBER
182   ) RETURN BOOLEAN AS
183   /*
184   ||  Created By : prchandr
185   ||  Created On : 07-FEB-2002
186   ||  Purpose : Validates the Primary Key of the table.
187   ||  Known limitations, enhancements or remarks :
188   ||  Change History :
189   ||  Who             When            What
190   ||  (reverse chronological order - newest change first)
191   */
192     CURSOR cur_rowid IS
193       SELECT   rowid
194       FROM     igs_co_mapping
195       WHERE    map_id = x_map_id
196       FOR UPDATE NOWAIT;
197 
198     lv_rowid cur_rowid%RowType;
199 
200   BEGIN
201 
202     OPEN cur_rowid;
203     FETCH cur_rowid INTO lv_rowid;
204     IF (cur_rowid%FOUND) THEN
205       CLOSE cur_rowid;
206       RETURN(TRUE);
207     ELSE
208       CLOSE cur_rowid;
209       RETURN(FALSE);
210     END IF;
211 
212   END get_pk_for_validation;
213 
214 
215   FUNCTION get_uk_for_validation (
216     x_document_id                       IN     NUMBER,
217     x_map_code                          IN     VARCHAR2,
218     x_sys_ltr_code                      IN     VARCHAR2
219   ) RETURN BOOLEAN AS
220   /*
221   ||  Created By : prchandr
222   ||  Created On : 07-FEB-2002
223   ||  Purpose : Validates the Unique Keys of the table.
224   ||  Known limitations, enhancements or remarks :
225   ||  Change History :
226   ||  Who             When            What
227   ||  (reverse chronological order - newest change first)
228   */
229     CURSOR cur_rowid IS
230       SELECT   rowid
231       FROM     igs_co_mapping
232       WHERE    document_id = x_document_id
233       AND      map_code = x_map_code
234       AND      sys_ltr_code = x_sys_ltr_code
235       AND      ((l_rowid IS NULL) OR (rowid <> l_rowid))
236       AND      enable_flag='Y';
237 
238     lv_rowid cur_rowid%RowType;
239 
240   BEGIN
241 
242     OPEN cur_rowid;
243     FETCH cur_rowid INTO lv_rowid;
244     IF (cur_rowid%FOUND) THEN
245       CLOSE cur_rowid;
246         RETURN (true);
247         ELSE
248        CLOSE cur_rowid;
249       RETURN(FALSE);
250     END IF;
251 
252   END get_uk_for_validation ;
253 
254 
255   PROCEDURE before_dml (
256     p_action                            IN     VARCHAR2,
257     x_rowid                             IN     VARCHAR2    DEFAULT NULL,
258     x_map_id                            IN     NUMBER      DEFAULT NULL,
259     x_map_code                          IN     VARCHAR2    DEFAULT NULL,
260     x_doc_code                          IN     VARCHAR2    DEFAULT NULL,
261     x_document_id                       IN     NUMBER      DEFAULT NULL,
262     x_enable_flag                       IN     VARCHAR2    DEFAULT NULL,
263     x_sys_ltr_code                      IN     VARCHAR2    DEFAULT NULL,
264     x_map_description                   IN     VARCHAR2    DEFAULT NULL,
265     x_elapsed_days                      IN     NUMBER      DEFAULT NULL,
266     x_repeat_times                      IN     NUMBER      DEFAULT NULL,
267     x_attr_description                  IN     VARCHAR2    DEFAULT NULL,
268     x_creation_date                     IN     DATE        DEFAULT NULL,
269     x_created_by                        IN     NUMBER      DEFAULT NULL,
270     x_last_update_date                  IN     DATE        DEFAULT NULL,
271     x_last_updated_by                   IN     NUMBER      DEFAULT NULL,
272     x_last_update_login                 IN     NUMBER      DEFAULT NULL
273   ) AS
274   /*
275   ||  Created By : prchandr
276   ||  Created On : 07-FEB-2002
277   ||  Purpose : Initialises the columns, Checks Constraints, Calls the
278   ||            Trigger Handlers for the table, before any DML operation.
279   ||  Known limitations, enhancements or remarks :
280   ||  Change History :
281   ||  Who             When            What
282   ||  (reverse chronological order - newest change first)
283   */
284   BEGIN
285 
286     set_column_values (
287       p_action,
288       x_rowid,
289       x_map_id,
290       x_map_code,
291       x_doc_code,
292       x_document_id,
293       x_enable_flag,
294       x_sys_ltr_code,
295       x_map_description,
296       x_elapsed_days,
297       x_repeat_times,
298       x_attr_description,
299       x_creation_date,
300       x_created_by,
301       x_last_update_date,
302       x_last_updated_by,
303       x_last_update_login
304     );
305 
306     IF (p_action = 'INSERT') THEN
307       -- Call all the procedures related to Before Insert.
308       IF ( get_pk_for_validation(
309              new_references.map_id
310            )
311          ) THEN
312         fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
313         igs_ge_msg_stack.add;
314         app_exception.raise_exception;
315       END IF;
316       check_uniqueness;
317       check_parent_existance;
318     ELSIF (p_action = 'UPDATE') THEN
319       -- Call all the procedures related to Before Update.
320       check_uniqueness;
321       check_parent_existance;
322     ELSIF (p_action = 'VALIDATE_INSERT') THEN
323       -- Call all the procedures related to Before Insert.
324       IF ( get_pk_for_validation (
325              new_references.map_id
326            )
327          ) THEN
328         fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
329         igs_ge_msg_stack.add;
330         app_exception.raise_exception;
331       END IF;
332       check_uniqueness;
333     ELSIF (p_action = 'VALIDATE_UPDATE') THEN
334       check_uniqueness;
335     END IF;
336 
337   END before_dml;
338 
339 
340   PROCEDURE insert_row (
341     x_rowid                             IN OUT NOCOPY VARCHAR2,
342     x_map_id                            IN OUT NOCOPY NUMBER,
343     x_map_code                          IN     VARCHAR2,
344     x_doc_code                          IN     VARCHAR2,
345     x_document_id                       IN     NUMBER,
346     x_enable_flag                       IN     VARCHAR2,
347     x_sys_ltr_code                      IN     VARCHAR2,
348     x_map_description                   IN     VARCHAR2,
349     x_elapsed_days                      IN     NUMBER,
350     x_repeat_times                      IN     NUMBER,
351     x_attr_description                  IN     VARCHAR2,
352     x_mode                              IN     VARCHAR2
353   ) AS
354   /*
355   ||  Created By : prchandr
356   ||  Created On : 07-FEB-2002
357   ||  Purpose : Handles the INSERT DML logic for the table.
358   ||  Known limitations, enhancements or remarks :
359   ||  Change History :
360   ||  Who             When            What
361   ||  (reverse chronological order - newest change first)
362   */
363     CURSOR c IS
364       SELECT   rowid
365       FROM     igs_co_mapping
366       WHERE    map_id                            = x_map_id;
367 
368     x_last_update_date           DATE;
369     x_last_updated_by            NUMBER;
370     x_last_update_login          NUMBER;
371 
372   BEGIN
373 
374     x_last_update_date := SYSDATE;
375     IF (x_mode = 'I') THEN
376       x_last_updated_by := 1;
377       x_last_update_login := 0;
378     ELSIF (x_mode = 'R') THEN
379       x_last_updated_by := fnd_global.user_id;
380       IF (x_last_updated_by IS NULL) THEN
381         x_last_updated_by := -1;
382       END IF;
383       x_last_update_login := fnd_global.login_id;
384       IF (x_last_update_login IS NULL) THEN
385         x_last_update_login := -1;
386       END IF;
387     ELSE
388       fnd_message.set_name ('FND', 'SYSTEM-INVALID ARGS');
389       igs_ge_msg_stack.add;
390       app_exception.raise_exception;
391     END IF;
392 
393     SELECT    igs_co_mapping_s.NEXTVAL
394     INTO      x_map_id
395     FROM      dual;
396 
397     before_dml(
398       p_action                            => 'INSERT',
399       x_rowid                             => x_rowid,
400       x_map_id                            => x_map_id,
401       x_map_code                          => x_map_code,
402       x_doc_code                          => x_doc_code,
403       x_document_id                       => x_document_id,
404       x_enable_flag                       => x_enable_flag,
405       x_sys_ltr_code                      => x_sys_ltr_code,
406       x_map_description                   => x_map_description,
407       x_elapsed_days                      => x_elapsed_days,
408       x_repeat_times                      => x_repeat_times,
409       x_attr_description                  => x_attr_description,
410       x_creation_date                     => x_last_update_date,
411       x_created_by                        => x_last_updated_by,
412       x_last_update_date                  => x_last_update_date,
413       x_last_updated_by                   => x_last_updated_by,
414       x_last_update_login                 => x_last_update_login
415     );
416 
417     INSERT INTO igs_co_mapping (
418       map_id,
419       map_code,
420       doc_code,
421       document_id,
422       enable_flag,
423       sys_ltr_code,
424       map_description,
425       elapsed_days,
426       repeat_times,
427       attr_description,
428       creation_date,
429       created_by,
430       last_update_date,
431       last_updated_by,
432       last_update_login
433     ) VALUES (
434       new_references.map_id,
435       new_references.map_code,
436       new_references.doc_code,
437       new_references.document_id,
438       new_references.enable_flag,
439       new_references.sys_ltr_code,
440       new_references.map_description,
441       new_references.elapsed_days,
442       new_references.repeat_times,
443       new_references.attr_description,
444       x_last_update_date,
445       x_last_updated_by,
446       x_last_update_date,
447       x_last_updated_by,
448       x_last_update_login
449     );
450 
451     OPEN c;
452     FETCH c INTO x_rowid;
453     IF (c%NOTFOUND) THEN
454       CLOSE c;
455       RAISE NO_DATA_FOUND;
456     END IF;
457     CLOSE c;
458 
459   END insert_row;
460 
461 
462   PROCEDURE lock_row (
463     x_rowid                             IN     VARCHAR2,
464     x_map_id                            IN     NUMBER,
465     x_map_code                          IN     VARCHAR2,
466     x_doc_code                          IN     VARCHAR2,
467     x_document_id                       IN     NUMBER,
468     x_enable_flag                       IN     VARCHAR2,
469     x_sys_ltr_code                      IN     VARCHAR2,
470     x_map_description                   IN     VARCHAR2,
471     x_elapsed_days                      IN     NUMBER,
472     x_repeat_times                      IN     NUMBER,
473     x_attr_description                  IN     VARCHAR2
474   ) AS
475   /*
476   ||  Created By : prchandr
477   ||  Created On : 07-FEB-2002
478   ||  Purpose : Handles the LOCK mechanism for the table.
479   ||  Known limitations, enhancements or remarks :
480   ||  Change History :
481   ||  Who             When            What
482   ||  (reverse chronological order - newest change first)
483   */
484     CURSOR c1 IS
485       SELECT
486         map_code,
487         doc_code,
488         document_id,
489         enable_flag,
490         sys_ltr_code,
491         map_description,
492         elapsed_days,
493         repeat_times,
494         attr_description
495       FROM  igs_co_mapping
496       WHERE rowid = x_rowid
497       FOR UPDATE NOWAIT;
498 
499     tlinfo c1%ROWTYPE;
500 
501   BEGIN
502 
503     OPEN c1;
504     FETCH c1 INTO tlinfo;
505     IF (c1%notfound) THEN
506       fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
507       igs_ge_msg_stack.add;
508       CLOSE c1;
509       app_exception.raise_exception;
510       RETURN;
511     END IF;
512     CLOSE c1;
513 
514     IF (
515         (tlinfo.map_code = x_map_code)
516         AND (tlinfo.doc_code = x_doc_code)
517         AND (tlinfo.document_id = x_document_id)
518         AND (tlinfo.enable_flag = x_enable_flag)
519         AND (tlinfo.sys_ltr_code = x_sys_ltr_code)
520         AND ((tlinfo.map_description = x_map_description) OR ((tlinfo.map_description IS NULL) AND (X_map_description IS NULL)))
521         AND ((tlinfo.elapsed_days = x_elapsed_days) OR ((tlinfo.elapsed_days IS NULL) AND (X_elapsed_days IS NULL)))
522         AND ((tlinfo.repeat_times = x_repeat_times) OR ((tlinfo.repeat_times IS NULL) AND (X_repeat_times IS NULL)))
523         AND ((tlinfo.attr_description = x_attr_description) OR ((tlinfo.attr_description IS NULL) AND (X_attr_description IS NULL)))
524        ) THEN
525       NULL;
526     ELSE
527       fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
528       igs_ge_msg_stack.add;
529       app_exception.raise_exception;
530     END IF;
531 
532     RETURN;
533 
534   END lock_row;
535 
536 
537   PROCEDURE update_row (
538     x_rowid                             IN     VARCHAR2,
539     x_map_id                            IN     NUMBER,
540     x_map_code                          IN     VARCHAR2,
541     x_doc_code                          IN     VARCHAR2,
542     x_document_id                       IN     NUMBER,
543     x_enable_flag                       IN     VARCHAR2,
544     x_sys_ltr_code                      IN     VARCHAR2,
545     x_map_description                   IN     VARCHAR2,
546     x_elapsed_days                      IN     NUMBER,
547     x_repeat_times                      IN     NUMBER,
548     x_attr_description                  IN     VARCHAR2,
549     x_mode                              IN     VARCHAR2
550   ) AS
551   /*
552   ||  Created By : prchandr
553   ||  Created On : 07-FEB-2002
554   ||  Purpose : Handles the UPDATE DML logic for the table.
555   ||  Known limitations, enhancements or remarks :
556   ||  Change History :
557   ||  Who             When            What
558   ||  (reverse chronological order - newest change first)
559   */
560     x_last_update_date           DATE ;
561     x_last_updated_by            NUMBER;
562     x_last_update_login          NUMBER;
563 
564   BEGIN
565 
566     x_last_update_date := SYSDATE;
567     IF (X_MODE = 'I') THEN
568       x_last_updated_by := 1;
569       x_last_update_login := 0;
570     ELSIF (x_mode = 'R') THEN
571       x_last_updated_by := fnd_global.user_id;
572       IF x_last_updated_by IS NULL THEN
573         x_last_updated_by := -1;
574       END IF;
575       x_last_update_login := fnd_global.login_id;
576       IF (x_last_update_login IS NULL) THEN
577         x_last_update_login := -1;
578       END IF;
579     ELSE
580       fnd_message.set_name( 'FND', 'SYSTEM-INVALID ARGS');
581       igs_ge_msg_stack.add;
582       app_exception.raise_exception;
583     END IF;
584 
585     before_dml(
586       p_action                            => 'UPDATE',
587       x_rowid                             => x_rowid,
588       x_map_id                            => x_map_id,
589       x_map_code                          => x_map_code,
590       x_doc_code                          => x_doc_code,
591       x_document_id                       => x_document_id,
592       x_enable_flag                       => x_enable_flag,
593       x_sys_ltr_code                      => x_sys_ltr_code,
594       x_map_description                   => x_map_description,
595       x_elapsed_days                      => x_elapsed_days,
596       x_repeat_times                      => x_repeat_times,
597       x_attr_description                  => x_attr_description,
598       x_creation_date                     => x_last_update_date,
599       x_created_by                        => x_last_updated_by,
600       x_last_update_date                  => x_last_update_date,
601       x_last_updated_by                   => x_last_updated_by,
602       x_last_update_login                 => x_last_update_login
603     );
604 
605     UPDATE igs_co_mapping
606       SET
607         map_code                          = new_references.map_code,
608         doc_code                          = new_references.doc_code,
609         document_id                       = new_references.document_id,
610         enable_flag                       = new_references.enable_flag,
611         sys_ltr_code                      = new_references.sys_ltr_code,
612         map_description                   = new_references.map_description,
613         elapsed_days                      = new_references.elapsed_days,
614         repeat_times                      = new_references.repeat_times,
615         attr_description                  = new_references.attr_description,
616         last_update_date                  = x_last_update_date,
617         last_updated_by                   = x_last_updated_by,
618         last_update_login                 = x_last_update_login
619       WHERE rowid = x_rowid;
620 
621     IF (SQL%NOTFOUND) THEN
622       RAISE NO_DATA_FOUND;
623     END IF;
624 
625   END update_row;
626 
627 
628   PROCEDURE add_row (
629     x_rowid                             IN OUT NOCOPY VARCHAR2,
630     x_map_id                            IN OUT NOCOPY NUMBER,
631     x_map_code                          IN     VARCHAR2,
632     x_doc_code                          IN     VARCHAR2,
633     x_document_id                       IN     NUMBER,
634     x_enable_flag                       IN     VARCHAR2,
635     x_sys_ltr_code                      IN     VARCHAR2,
636     x_map_description                   IN     VARCHAR2,
637     x_elapsed_days                      IN     NUMBER,
638     x_repeat_times                      IN     NUMBER,
639     x_attr_description                  IN     VARCHAR2,
640     x_mode                              IN     VARCHAR2
641   ) AS
642   /*
643   ||  Created By : prchandr
644   ||  Created On : 07-FEB-2002
645   ||  Purpose : Adds a row if there is no existing row, otherwise updates existing row in the table.
646   ||  Known limitations, enhancements or remarks :
647   ||  Change History :
648   ||  Who             When            What
649   ||  (reverse chronological order - newest change first)
650   */
651     CURSOR c1 IS
652       SELECT   rowid
653       FROM     igs_co_mapping
654       WHERE    map_id                            = x_map_id;
655 
656   BEGIN
657 
658     OPEN c1;
659     FETCH c1 INTO x_rowid;
660     IF (c1%NOTFOUND) THEN
661       CLOSE c1;
662 
663       insert_row (
664         x_rowid,
665         x_map_id,
666         x_map_code,
667         x_doc_code,
668         x_document_id,
669         x_enable_flag,
670         x_sys_ltr_code,
671         x_map_description,
672         x_elapsed_days,
673         x_repeat_times,
674         x_attr_description,
675         x_mode
676       );
677       RETURN;
678     END IF;
679     CLOSE c1;
680 
681     update_row (
682       x_rowid,
683       x_map_id,
684       x_map_code,
685       x_doc_code,
686       x_document_id,
687       x_enable_flag,
688       x_sys_ltr_code,
689       x_map_description,
690       x_elapsed_days,
691       x_repeat_times,
692       x_attr_description,
693       x_mode
694     );
695 
696   END add_row;
697 
698 
699   PROCEDURE delete_row (
700     x_rowid IN VARCHAR2
701   ) AS
702   /*
703   ||  Created By : prchandr
704   ||  Created On : 07-FEB-2002
705   ||  Purpose : Handles the DELETE DML logic for the table.
706   ||  Known limitations, enhancements or remarks :
707   ||  Change History :
708   ||  Who             When            What
709   ||  (reverse chronological order - newest change first)
710   */
711   BEGIN
712 
713     before_dml (
714       p_action => 'DELETE',
715       x_rowid => x_rowid
716     );
717 
718     DELETE FROM igs_co_mapping
719     WHERE rowid = x_rowid;
720 
721     IF (SQL%NOTFOUND) THEN
722       RAISE NO_DATA_FOUND;
723     END IF;
724 
725   END delete_row;
726 
727 
728 END igs_co_mapping_pkg;