This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License.


ORA-12054 for Materialized View on GL_CODE_COMBINATIONS

The below script was my second attempt to create a fast refresh Materialized View in Oracle. The last step in the scipt failed because Oracle is unable to create a Fast Materialized view referencing a package function because it deems this to be complicated.

Anyway, in the third attempt, we will do a trickery to fool Oracle...

conn apps/&1 ;
create materialized view log on GL.GL_CODE_COMBINATIONS
with rowid (
CODE_COMBINATION_ID
,CHART_OF_ACCOUNTS_ID
,DETAIL_POSTING_ALLOWED_FLAG
,DETAIL_BUDGETING_ALLOWED_FLAG
,ACCOUNT_TYPE
,ENABLED_FLAG
,SUMMARY_FLAG
,SEGMENT1
,SEGMENT2
,SEGMENT3
,SEGMENT4
,TEMPLATE_ID
,START_DATE_ACTIVE
,END_DATE_ACTIVE
)
including new values
;

conn gl/&4;
GRANT SELECT ON GL.GL_CODE_COMBINATIONS TO xxschema WITH GRANT OPTION;
GRANT ALL ON GL.MLOG$_GL_CODE_COMBINATIONS TO xxschema ;

conn apps/&1 ;

CREATE OR REPLACE PACKAGE xx_mv_util AS
FUNCTION get_vs_code_description(p_code IN VARCHAR2
,p_vs_id IN INTEGER) RETURN VARCHAR2;
PRAGMA RESTRICT_REFERENCES(get_vs_code_description
,WNDS
,WNPS
,RNPS);
END xx_mv_util;
/

GRANT ALL ON xx_mv_util TO xxschema ;

CREATE OR REPLACE PACKAGE BODY xx_mv_util AS
FUNCTION get_vs_code_description(p_code IN VARCHAR2
,p_vs_id IN INTEGER) RETURN VARCHAR2 IS
CURSOR c_get IS
SELECT ffv.description
FROM fnd_flex_values_vl ffv
WHERE flex_value_set_id = p_vs_id
AND flex_value = p_code;
p_get c_get%ROWTYPE;
BEGIN
OPEN c_get;
FETCH c_get
INTO p_get;
CLOSE c_get;
RETURN p_get.description;
END get_vs_code_description;
END xx_mv_util;
/

create table xxschema.IC_GL_CODE_COMBINATIONS_MV AS
SELECT cc.segment2 costcentre
,xx_mv_util.get_vs_code_description(cc.segment2, 1002651) AS costcentre_desc
,cc.segment3 activity
,xx_mv_util.get_vs_code_description(cc.segment3,1002652) activity_desc
,cc.segment4 analysis
,cc.segment4 new_analysis
,xx_mv_util.get_vs_code_description(cc.segment4,1002653) AS analysis_desc
,cc.code_combination_id
FROM gl.gl_code_combinations cc ;

create materialized view IC_GL_CODE_COMBINATIONS_MV
on prebuilt table
refresh fast
on commit
as
SELECT
cc.segment2 costcentre
,xx_mv_util.get_vs_code_description(cc.segment2, 1002651) AS costcentre_desc
,cc.segment3 activity
,xx_mv_util.get_vs_code_description(cc.segment3,1002652) activity_desc
,cc.segment4 analysis
,cc.segment4 new_analysis
,xx_mv_util.get_vs_code_description(cc.segment4,1002653) AS analysis_desc
,cc.code_combination_id
FROM gl.gl_code_combinations cc ;

This errors with
ERROR at line 13:
ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view

Comments on ""

 

post a comment