Hi All -
I've compiled the package below and cannot get the darn thing to run correctly. I've tried the following syntax in SQL*Plus:
exec tqr135t.cois_swexpense_preprocess.process_fixed_assets(tqr135t.cois_swexpense_preprocess.fa_extract);
and gotten the following error:
While processing data from the Fixed Assets source, ORA-06504: PL/SQL: Return
types of Result Set variables or query do not match
What do I need to add to the syntax to make this run correctly? Nothing that I've tried works correctly.
HELP!!!!
I've compiled the package below and cannot get the darn thing to run correctly. I've tried the following syntax in SQL*Plus:
exec tqr135t.cois_swexpense_preprocess.process_fixed_assets(tqr135t.cois_swexpense_preprocess.fa_extract);
and gotten the following error:
While processing data from the Fixed Assets source, ORA-06504: PL/SQL: Return
types of Result Set variables or query do not match
What do I need to add to the syntax to make this run correctly? Nothing that I've tried works correctly.
HELP!!!!
Code:
CREATE OR REPLACE PACKAGE BODY TQR135T.COIS_SWEXPENSE_PREPROCESS IS
FUNCTION fa_extract RETURN sys_refcursor IS
fa_rc sys_refcursor;
BEGIN
OPEN fa_rc FOR
SELECT co, center, asset, description, catgry, curr_depr, proj_num, addl_desc
FROM caa.cois_fixed_assets_stage
WHERE asset IN (
SELECT asset FROM caa.cois_swexpense_definitions)
AND catgry IN (
SELECT category FROM caa.cois_swexpense_definitions)
AND co = '2001';
RETURN fa_rc;
END fa_extract;
PROCEDURE process_fixed_assets(fa_rc sys_refcursor) IS
f caa.cois_fixed_assets_stage%ROWTYPE;
BEGIN
LOOP
FETCH fa_rc INTO f;
EXIT WHEN fa_rc%NOTFOUND;
UPDATE caa.cois_swexpense_source
SET app_id = f.proj_num,
cost_center=f.center,
asset = f.asset,
amount = f.curr_depr,
description = f.addl_desc,
category = f.catgry,
modified_date=sysdate;
UPDATE caa.cois_swexpense_source
SET org_unit_id = TO_NUMBER(CONCAT(f.co, f.center), '99999999999.')
WHERE cost_center = f.center;
END LOOP;
COMMIT;
EXCEPTION
WHEN others THEN DBMS_OUTPUT.PUT_LINE('While processing data from the Fixed Assets source, '||sqlerrm);
END process_fixed_assets;
FUNCTION mt_extract RETURN sys_refcursor IS
mt_rc sys_refcursor;
BEGIN
OPEN mt_rc FOR
SELECT bank, gl_account, cost_center, source_code, amount, description_2
FROM caa.cois_master_trans_stage;
RETURN mt_rc;
END mt_extract;
PROCEDURE process_master_transaction(mt_rc sys_refcursor) IS
m caa.cois_master_trans_stage%ROWTYPE;
BEGIN
LOOP
FETCH mt_rc INTO m;
EXIT WHEN mt_rc%NOTFOUND;
UPDATE caa.cois_swexpense_source
SET gl_account=m.gl_account,
cost_center=m.cost_center,
source_code=m.source_code,
amount=m.amount,
app_id=m.description_2,
modified_date=sysdate;
UPDATE caa.cois_swexpense_source
SET org_unit_id = TO_NUMBER(CONCAT(m.bank, m.cost_center), '99999999999.')
WHERE cost_center = m.cost_center;
END LOOP;
COMMIT;
EXCEPTION
WHEN others THEN DBMS_OUTPUT.PUT_LINE('While processing data from the Master Transaction source, '||sqlerrm);
END process_master_transaction;
PROCEDURE swexpense_validation IS
CURSOR bai IS
SELECT app_id FROM caa.cois_swexpense_source
WHERE app_id NOT IN
(SELECT app_id FROM caa.cois_app_id);
bad_app_id VARCHAR2(5);
BEGIN
FOR app_code IN (SELECT app_id FROM caa.cois_swexpense_source) LOOP
OPEN bai;
FETCH bai INTO bad_app_id;
INSERT INTO caa.cois_process_validation (source, value, error, process_date)
VALUES ('Software Expense, APP_ID', bad_app_id, 'APP_ID '||bad_app_id||' is not contained in the COIS_APP_ID table.', sysdate);
CLOSE bai;
END LOOP;
COMMIT;
EXCEPTION
WHEN others THEN DBMS_OUTPUT.PUT_LINE('While validating cois_swexpense_source, '||sqlerrm);
END swexpense_validation;
END;
/