DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHG_TRANSACTIONS_HISTORY_PKG

Source


1 PACKAGE BODY GHG_TRANSACTIONS_HISTORY_PKG AS
2 /*$Header: ghgtxnhb.pls 120.1 2011/10/31 08:32:32 pwaghmar noship $ */
3 
4 /** Need to check History table for extra fields */
5 
6 PROCEDURE insert_row (x_transaction_id NUMBER) IS
7 
8 v_package          VARCHAR2(100);
9 v_debug_info       VARCHAR2(100);
10 v_transaction_version NUMBER(15) := 1;
11 
12 BEGIN
13 
14   v_package := 'GHG_TRANSACTIONS_HISTORY_PKG.insert_row';
15   v_debug_info := 'Inserting into GHG_TRANSACTIONS_HISTORY_ALL';
16 
17   BEGIN
18 
19     SELECT MAX(transaction_version)
20     INTO   v_transaction_version
21     FROM   GHG_TRANSACTIONS_HISTORY_ALL
22     WHERE  transaction_id = x_transaction_id;
23 
24     EXCEPTION
25       WHEN NO_DATA_FOUND THEN
26         NULL;
27 
28   END;
29 
30   v_transaction_version := NVL(v_transaction_version, 0) + 1;
31 
32 
33   INSERT INTO GHG_TRANSACTIONS_HISTORY_ALL
34              (txn_type_lookup_code,
35               transaction_id,
36               transaction_version,
37               --emission_rate_id,
38               ghg_organization_id,
39               transaction_type_lookup_code,
40               usage_quantity,
41               unit_of_measure,
42               uom_conversion,
43               emission_quantity,
44               energy_quantity,
45               transaction_date_from,
46               transaction_date_to,
47               description,
48               org_id,
49               set_of_books_id,
50               invoice_id,
51               transaction_line_number,
52               distribution_line_number,
53               invoice_line_number,
54               vendor_id,
55               vendor_site_id,
56               attribute1,
57               attribute2,
58               attribute3,
59               attribute4,
60               attribute5,
61               attribute6,
62               attribute7,
63               attribute8,
64               attribute9,
65               attribute10,
66               attribute11,
67               attribute12,
68               attribute13,
69               attribute14,
70               attribute15,
71               attribute16,
72               attribute17,
73               attribute18,
74               attribute19,
75               attribute20,
76               attribute_category,
77               created_by,
78               creation_date,
79               last_updated_by,
80               last_update_date,
81               last_update_login,
82               MEASUREMENT_CRITERIA)
83   SELECT      xne.txn_type_lookup_code,
84               xne.transaction_id,
85               v_transaction_version,
86               --xne.emission_rate_id,
87               --xne.transaction_source_id,
88               xne.ghg_organization_id,
89               xne.transaction_type_lookup_code,
90               xne.usage_quantity,
91               xne.unit_of_measure,
92               xne.uom_conversion,
93               xne.emission_quantity,
94               xne.energy_quantity,
95               xne.transaction_date_from,
96               xne.transaction_date_to,
97               xne.description,
98               xne.org_id,
99               xne.set_of_books_id,
100               xne.invoice_id,
101               xne.transaction_line_number,
102               xne.distribution_line_number,
103               xne.invoice_line_number,
104               xne.vendor_id,
105               xne.vendor_site_id,
106               xne.attribute1,
107               xne.attribute2,
108               xne.attribute3,
109               xne.attribute4,
110               xne.attribute5,
111               xne.attribute6,
112               xne.attribute7,
113               xne.attribute8,
114               xne.attribute9,
115               xne.attribute10,
116               xne.attribute11,
117               xne.attribute12,
118               xne.attribute13,
119               xne.attribute14,
120               xne.attribute15,
121               xne.attribute16,
122               xne.attribute17,
123               xne.attribute18,
124               xne.attribute19,
125               xne.attribute20,
126               xne.attribute_category,
127               xne.created_by,
128               xne.creation_date,
129               xne.last_updated_by,
130               xne.last_update_date,
131               xne.last_update_login,
132               MEASUREMENT_CRITERIA
133   FROM  GHG_TRANSACTIONS_V xne
134   WHERE xne.transaction_id = x_transaction_id;
135 
136   EXCEPTION
137      WHEN OTHERS THEN
138         IF (SQLCODE <> -20001) THEN
139            FND_MESSAGE.SET_NAME('GHG', 'GHG_DEBUG');
140            FND_MESSAGE.SET_TOKEN('ERROR', SQLERRM);
141            FND_MESSAGE.SET_TOKEN('ERROR',x_transaction_id );
142            FND_MESSAGE.SET_TOKEN('DEBUG_INFO', v_package ||' : ' ||v_debug_info);
143        END IF;
144        APP_EXCEPTION.RAISE_EXCEPTION;
145 
146 END insert_row;
147 
148 END GHG_TRANSACTIONS_HISTORY_PKG;