The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT GSB.currency_code
INTO x_base_currency
FROM FINANCIALS_SYSTEM_PARAMETERS FSP,
GL_SETS_OF_BOOKS GSB
WHERE FSP.set_of_books_id = GSB.set_of_books_id
AND FSP.ORG_ID=p_org_id;
SELECT GSB.currency_code,
POH.currency_code
INTO x_base_currency,
x_po_currency
FROM PO_HEADERS_ALL POH, -- Bug 3012328 (Changed to all table so that this does not fail for GA's)
FINANCIALS_SYSTEM_PARAMS_ALL FSP, -- Bug 5221311 Changed to all table
GL_SETS_OF_BOOKS GSB
WHERE POH.po_header_id = x_object_id
AND FSP.set_of_books_id = GSB.set_of_books_id
AND FSP.org_id = POH.org_id; --< R12 MOAC>
SELECT gsb.currency_code
INTO x_currency_code
FROM financials_system_params_all fsp,
gl_sets_of_books gsb
WHERE fsp.set_of_books_id = gsb.set_of_books_id
AND fsp.org_id = p_org_id;
SELECT GSB.currency_code
INTO x_currency_code
FROM FINANCIALS_SYSTEM_PARAMETERS FSP,
GL_SETS_OF_BOOKS GSB
WHERE FSP.set_of_books_id = GSB.set_of_books_id;
SELECT POH.currency_code,
POH.rate_type,
POH.rate_date,
POH.rate
INTO x_currency_code,
x_curr_rate_type,
x_curr_rate_date,
x_currency_rate
FROM PO_HEADERS_ALL POH
WHERE POH.po_header_id = p_po_header_id;
SELECT PO_SESSION_GT_S.nextval
INTO l_transaction_id
FROM DUAL;
INSERT INTO PO_SESSION_GT TEMP
(
key
, num1 --sequence number
, num2 --input amount
, num3 --exchange rate
, num4 --from currency precision
, num5 --from currency MAU
, num6 --to currency precision
, num7 --to currency MAU
, char1 --round only flag (to skip currency convert)
)
VALUES
(
l_transaction_id
, p_unique_id_tbl(i) --bug 4878973: use this instead of rownum
, p_amount_in_tbl(i)
, NVL(p_exchange_rate_tbl(i), 1)
, p_from_currency_precision_tbl(i)
, p_from_currency_mau_tbl(i)
, p_to_currency_precision_tbl(i)
, p_to_currency_mau_tbl(i)
, NVL(p_round_only_flag_tbl(i), 'N') --bug 3568671
)
;
UPDATE PO_SESSION_GT TEMP
SET TEMP.num2 =
( DECODE( TEMP.num5
-- if from MAU is null, use precision
-- if precision null, don't round at all.
, NULL, DECODE( temp.num4
, NULL, TEMP.num2
, round(TEMP.num2, TEMP.num4)
)
-- if MAU not null, use MAU
, (round (TEMP.num2 / TEMP.num5) * TEMP.num5)
)
* TEMP.num3 --exchange rate
)
WHERE TEMP.key = l_transaction_id
--bug 3568671: do not do this first calculation if the caller
--has specified to skip the currency conversion step
AND TEMP.char1 = 'N'
;
UPDATE PO_SESSION_GT TEMP
SET TEMP.num8 = --output amount
( DECODE( TEMP.num7
-- if MAU is null, use precision
-- if precision null, don't round at all
, NULL, DECODE( temp.num6
, NULL, TEMP.num2
, round(TEMP.num2, TEMP.num6)
)
-- if MAU not null, use MAU
, (round (TEMP.num2 / TEMP.num7) * TEMP.num7)
)
)
WHERE TEMP.key = l_transaction_id
;
SELECT rowid BULK COLLECT INTO PO_DEBUG.g_rowid_tbl
FROM PO_SESSION_GT WHERE key = l_transaction_id;
SELECT TEMP.num8
BULK COLLECT INTO x_amount_out_tbl
FROM PO_SESSION_GT TEMP
WHERE TEMP.key = l_transaction_id
ORDER BY TEMP.num1; --input and output tbls have same ordering