DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGS_DA_FTR_VAL_MAP_PKG

Source


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