Wednesday, May 27, 2015

ORA-04061: existing state of package body and ORA-04065: not executed


found below issue while compiling package by two different uses.
============================================
ORA-04061: existing state of package body "test.test_PKG" has been invalidated
ORA-04065: not executed, altered or dropped package body "test.test_PKG"
ORA-06508: PL/SQL: could not find program unit being called: "test.test_PKG" 9:53 PM
Caused by: org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call TEST1_PKG.matchUpdatedInventory(?, ?, ?, ?, ?)}]; SQL state [72000]; ERROR code [4068]; ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package "TEST1.TEST1_PKG" has been invalidated
ORA-04065: not executed, altered or dropped package "TEST1.TEST1_PKG"
ORA-06508: PL/SQL: could not find program unit being called: "TEST1.TEST1_PKG"
ORA-06512: at line 1


Solution :

flushed shared pool fixed the issue.

cause: in the shared pool old compilation status was there. 

Wednesday, May 6, 2015

ORA-8104 "This index object %s is being online built or rebuilt."

ORA-8104 "This index object %s is being online built or rebuilt."

occur during if some one manually killed or terminated index rebuild script in half way.

fix
==========
SQL> select i.obj#, i.flags, u.name, o.name, o.type#    from sys.obj$ o, sys.user$ u, sys.ind$ idx, sys.ind_online$ I   where  bitand(i.flags, 512) = 512 and o.obj#=idx.obj# and
          o.owner# = u.user# and idx.obj#=i.obj#;
      OBJ#      FLAGS  NAME     TYPE#
---------- ---------- --------------------------------------------------
    1501151       2563 test user PK_TESTUSER


SQL> show user
USER is "SYS"
SQL> DECLARE
  2  isClean BOOLEAN;
  3  BEGIN
  4  isClean := DBMS_REPAIR.ONLINE_INDEX_CLEAN();
  5  END;
  6  /

PL/SQL procedure successfully completed.

SQL> commit;

Commit complete.

SQL>  select i.obj#, i.flags, u.name, o.name, o.type# 
  from sys.obj$ o, sys.user$ u, sys.ind$ idx, sys.ind_online$ i
  where  bitand(i.flags, 512) = 512 and o.obj#=idx.obj# and
          o.owner# = u.user# and idx.obj#=i.obj#;  2    3    4 

no rows selected

SQL>


execute 

alter index "index_name" rebuild online;
  

Partition table/index rebuild steps

Use below steps to generate rebuild scripts for table and indexes and execute o/p on database. 

select  'alter table '||OWNER||'.'||SEGMENT_NAME||' '||'move partition '||PARTITION_NAME ||';' from dba_segments where OWNER='ADMUSER' AND SEGMENT_NAME='TEST1';

select 'alter index '||index_owner||'.'||index_name||' rebuild partition '|| PARTITION_NAME ||';' from dba_ind_partitions   where index_name in (select  index_name from dba_indexes where table_name='TEST1')



Verify the index status using below scripts

select INDEX_OWNER , INDEX_NAME , STATUS from dba_ind_partitions where STATUS='UNUSABLE'
 select index_name , status , owner from dba_indexes where status='UNUSABLE'