DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGS_PS_NSUS_RTN_PKG

Source


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