DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_ADD_WARRANTY_PKG

Source


1 PACKAGE BODY FA_ADD_WARRANTY_PKG AS
2 /* $Header: FAADDWRB.pls 120.3 2009/03/27 05:38:24 bridgway ship $ */
3 
4   PROCEDURE Update_Table(WR_warranty_id      NUMBER,
5                      WR_old_warranty_id      NUMBER,
6 		     WR_asset_id         NUMBER,
7 		     WR_date_effective   DATE DEFAULT sysdate,
8 		     WR_date_ineffective  DATE,
9 		     WR_last_update_date DATE,
10 		     WR_last_updated_by  NUMBER,
11 		     WR_created_by       NUMBER DEFAULT -1,
12 		     WR_creation_date    DATE DEFAULT sysdate,
13 		     WR_last_update_login NUMBER DEFAULT -1,
14 		     WR_update_row       VARCHAR2,
15 		     WR_insert_row       VARCHAR2,
16 		     WR_calling_fn	 VARCHAR2, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type)   IS
17 
18 	h_date_effective 	DATE;
19 	h_last_update_date	DATE;
20 	h_last_updated_by	NUMBER;
21   BEGIN
22 
23 	--Assigning the values to the parameters explicitly because the 'DEFAULT'
24 	--clause in the formal parameters definition does not work.
25 	h_date_effective   := WR_date_effective;
26 	h_last_update_date := WR_last_update_date;
27 	h_last_updated_by  := WR_last_updated_by;
28 
29 	IF (h_date_effective IS NULL) THEN
30 		h_date_effective := sysdate;
31 	END IF;
32 
33 	IF (h_last_update_date IS NULL) THEN
34 		h_last_update_date := sysdate;
35 	END IF;
36 
37 	IF (h_last_updated_by IS NULL) THEN
38 		h_last_updated_by := -1;
39 	END IF;
40 
41 
42 	IF (WR_update_row = 'YES') THEN
43  	 	Update_Row(X_old_warranty_id    =>WR_old_warranty_id ,
44 		     X_asset_id         =>WR_asset_id,
45 		     X_date_ineffective =>WR_date_ineffective,
46 		     X_last_update_date =>h_last_update_date,
47 		     X_last_updated_by  =>h_last_updated_by ,
48 		     X_last_update_login=>WR_last_update_login ,
49 		     X_calling_fn	=>'FA_ADD_WARRANTY_PKG.Update_Table', p_log_level_rec => p_log_level_rec);
50 	END IF;
51 
52 	IF (WR_insert_row = 'YES') THEN
53 	  	Insert_Row(X_warranty_id=>WR_warranty_id ,
54 		     X_asset_id         =>WR_asset_id,
55 		     X_date_effective   =>h_date_effective ,
56 		     X_last_update_date =>h_last_update_date,
57 		     X_last_updated_by  =>h_last_updated_by ,
58 		     X_created_by       =>WR_created_by,
59 		     X_creation_date    =>WR_creation_date,
60 		     X_last_update_login=>WR_last_update_login ,
61 		     X_calling_fn	=>'FA_ADD_WARRANTY_PKG.Update_Table', p_log_level_rec => p_log_level_rec);
62 	END IF;
63 
64   EXCEPTION
65 	WHEN OTHERS THEN
66       	FA_STANDARD_PKG.RAISE_ERROR(
67 				CALLED_FN => 'FA_INS_WARRANTY_PKG.Update_Table',
68 				CALLING_FN => WR_calling_fn, p_log_level_rec => p_log_level_rec);
69   END Update_Table;
70 
71 
72 
73 --------------------------------------------------------------------------------------
74 
75   PROCEDURE Update_Row(X_old_warranty_id     NUMBER,
76 		     X_asset_id          NUMBER,
77 		     X_date_ineffective  DATE DEFAULT sysdate,
78 		     X_last_update_date  DATE DEFAULT sysdate,
79 		     X_last_updated_by   NUMBER DEFAULT -1,
80 		     X_last_update_login NUMBER DEFAULT -1,
81 		     X_calling_fn	 VARCHAR2, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type) IS
82   BEGIN
83   	UPDATE fa_add_warranties
84 	SET date_ineffective = X_date_ineffective,
85 	    last_update_date = X_last_update_date,
86 	    last_updated_by  = X_last_updated_by,
87 	    last_update_login= X_last_update_login
88 	WHERE asset_id = X_asset_id
89 	AND   warranty_id =  X_old_warranty_id
90 	AND   date_ineffective IS NULL;
91 
92   EXCEPTION
93 	WHEN OTHERS THEN
94 	      	FA_STANDARD_PKG.RAISE_ERROR(
95 				CALLED_FN => 'FA_INS_WARRANTY_PKG.Update_Row',
96 				CALLING_FN => X_calling_fn, p_log_level_rec => p_log_level_rec);
97   END Update_Row;
98 
99 
100 --------------------------------------------------------------------------------------
101 
102   PROCEDURE Insert_Row(X_warranty_id      NUMBER,
103 		     X_asset_id         NUMBER,
104 		     X_date_effective   DATE,
105 		     X_last_update_date DATE,
106 		     X_last_updated_by  NUMBER,
107 		     X_created_by       NUMBER DEFAULT -1,
108 		     X_creation_date    DATE DEFAULT sysdate,
109 		     X_last_update_login NUMBER DEFAULT -1,
110 		     X_calling_fn	 VARCHAR2, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type)   IS
111   BEGIN
112 	INSERT INTO fa_add_warranties(
113 	warranty_id,
114 	asset_id,
115 	date_effective,
116 	last_update_date,
117 	last_updated_by,
118 	created_by,
119 	creation_date,
120 	last_update_login)
121 	VALUES (X_warranty_id,
122 		X_asset_id,
123 		X_date_effective,
124 		X_last_update_date,
125 		X_last_updated_by,
126 		X_created_by,
127 		X_creation_date,
128 		X_last_update_login);
129   EXCEPTION
130 	when others then
131       	FA_STANDARD_PKG.RAISE_ERROR(
132 				CALLED_FN => 'FA_INS_WARRANTY_PKG.Insert_Row',
133 				CALLING_FN => X_calling_fn, p_log_level_rec => p_log_level_rec);
134   END Insert_Row;
135 
136 
137 END FA_ADD_WARRANTY_PKG;