Skip to main content

ORA-00947: not enough values when refreshing materialized views



This is typical scenario for customers using materialized views to replicate below error -


SQL> exec dbms_mview.refresh('SAMPLE_TB_MV','c',ATOMIC_REFRESH => FALSE);
BEGIN dbms_mview.refresh('SAMPLE_TB_MV','c',ATOMIC_REFRESH => FALSE); END;

*
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-00947: not enough values
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2821
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 3058
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 3017
ORA-06512: at line 1



Base Table -

create table sample_tb(id number primary key,name varchar2(10),val number);


Insert data -

insert into sample_tb values(1,'ABC',99);

Materialized View -

create materialized view sample_tb_mv
as
select * from sample_tb;

Check data -

select * from sample_tb;
        ID NAME              VAL
---------- ---------- ----------
         1 ABC                99


Check metadata -

SQL> set lines 170
set pages 1200
set long 9999999
select dbms_metadata.get_ddl ('MATERIALIZED_VIEW','SAMPLE_TB_MV') from dual;SQL> SQL> SQL>

DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','SAMPLE_TB_MV')
--------------------------------------------------------------------------------

  CREATE MATERIALIZED VIEW "SCOTT"."SAMPLE_TB_MV" ("ID", "NAME", "VAL")
  ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255


Drop column from base-table 

alter table sample_tb drop column val;

Check data for materialized view again -

select * from sample_tb_mv;
        ID NAME              VAL
---------- ---------- ----------
         1 ABC                99

Try to manually refresh again-

exec dbms_mview.refresh('SAMPLE_TB_MV','c',ATOMIC_REFRESH => FALSE);

SQL> exec dbms_mview.refresh('SAMPLE_TB_MV','c',ATOMIC_REFRESH => FALSE);
BEGIN dbms_mview.refresh('SAMPLE_TB_MV','c',ATOMIC_REFRESH => FALSE); END;

*
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-00947: not enough values
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2821
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 3058
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 3017
ORA-06512: at line 1

SQL>


Check metadata (mv metadata is still the same)- 

set lines 170
set pages 1200
set long 9999999
select dbms_metadata.get_ddl ('MATERIALIZED_VIEW','SAMPLE_TB_MV') from dual;
DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','SAMPLE_TB_MV')
--------------------------------------------------------------------------------

  CREATE MATERIALIZED VIEW "SCOTT"."SAMPLE_TB_MV" ("ID", "NAME", "VAL")
  ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255


Solution -


Drop and recreate materialized view -

SQL> drop  materialized view sample_tb_mv;

Materialized view dropped.

SQL> create materialized view sample_tb_mv
as
select * from sample_tb;


Try to refresh and check metadata again -

SQL> exec dbms_mview.refresh('SAMPLE_TB_MV','c',ATOMIC_REFRESH => FALSE);

PL/SQL procedure successfully completed.


SQL> set lines 170
set pages 1200
set long 9999999
select dbms_metadata.get_ddl ('MATERIALIZED_VIEW','SAMPLE_TB_MV') from dual;SQL> SQL> SQL>

DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','SAMPLE_TB_MV')
--------------------------------------------------------------------------------

  CREATE MATERIALIZED VIEW "SCOTT"."SAMPLE_TB_MV" ("ID", "NAME")
  ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
................



We can conclude that for ORA-00947: not enough values, on materialized views, we should follow below approach -

1. Check for metadata of both base table, materialized view log and materialized view.

2. Compare columns of base table and materialized view.


Before wrapping up, 2 clauses worth noticing for materialized views are -
a. preserve table-
This clause will be used with 'drop materialized view' command to make sure that materialized view is preserved as a stand alone table and this will save us some time when recreating materialized views.

b. on prebuilt table-
When recreating materialized view, we need to use this clause so that 'prebuilt table' that was preserved during 'delete materialized view' command is used.



Comments

Post a Comment

Popular posts from this blog

Logfile locations in EBS r12.1 and EBS r12.2

Startup/shutdown Apps tier services are started and stopped frequently and we must know logfiles when troubleshooting startup/shutdown issues. $INST_TOP/logs/appl/admin/log $INST_TOP/logs/appl/admin/log Apache OHS being part of opmn in r12.1 has continued in r12.2. Logfile locations for troubleshooting have been changed $INST_TOP/logs/ora/10.1.3/Apache/error_log[timestamp] $INST_TOP/logs/ora/10.1.3/opmn/HTTP_Server~1.log $IAS_ORACLE_HOME/instances/*/diagnostics/logs/OHS/*/*log*   OPMN Logfile locations for r12.1 and r12.2 have been changed $INST_TOP/logs/ora/10.1.3/opmn/opmn* $IAS_ORACLE_HOME/instances/*/diagnostics/logs/OPMN/opmn/* Oacore oacore in r12.1 is oc4j component and part of 10gAS. However, in r12.2, oacore is now a managed server for weblogic server $LOG_HOME/ora/10.1.3/j2ee/oacore/oacore*/ $LOG_HOME/ora/10.1.3/j2ee/oacore/oacore*/ $LOG_HOME/ora/10.1.3/opmn/oacore*/oacorestd

Query to Check AD and TXK code levels in your EBS environment

Below query can be very handy in finding out current AD and TXK code levels. col ABBREVIATION for a10 set lines 1000 col NAME for a50 col CODELEVEL for a20 SELECT ABBREVIATION,NAME,codelevel FROM AD_TRACKABLE_ENTITIES WHERE abbreviation in ('txk','ad'); ABBREVIATI NAME                                                CODELEVEL ---------- -------------------------------------------------- ------------ ad           Oracle Applications DBA                             C.11 txk         Oracle Applications Technology Stack                C.11

Compile all JSP files in Oracle ebs r12.2

Before you start compiling jsps and following below steps, I recommend understanding some key differences between 11i, r12.1 and r12.2 when it comes to compiling jsps. Please follow below link and then proceed further - One-stop shop to Compile JSPs in 11i, r12.1 and r12.2 1. Take a backup of _pages directory that will be modified due to jsp compilation - $ cd $EBS_APPS_DEPLOYMENT_DIR/oacore/html/WEB-INF/classes/ $ cp -R _pages _pages29dec2019 $ ls -ld _pages* drwxr-xr-x 5 applmgr oinstall 249856 Dec 29 16:36 _pages drwxr-xr-x 5 applmgr oinstall 249856 Dec 29 16:56 _pages29dec2019 2. Stop apache, oacore and oafm services - adapcctl.sh stop admanagedsrvctl.sh stop oacore_server1 admanagedsrvctl.sh stop oafm_server1 3. Compile the jsps manually using the below command - $ cd $FND_TOP/patch/115/bin/ $ perl $FND_TOP/patch/115/bin/ojspCompile.pl --compile --flush -p              4. Check class file last modification date as follows - $ cd $EBS_APPS_DEP