SQL> select count(*) from dba_objects where status='INVALID';
COUNT(*)
----------
44
SQL> select distinct object_type from dba_objects where status='INVALID';
OBJECT_TYPE
-------------------
PROCEDURE
VIEW
JAVA CLASS
JAVA SOURCE
SYNONYM
SQL> select owner,object_type,count(*) from dba_objects where status='INVALID' group by owner,object_type;
OWNER OBJECT_TYPE COUNT(*)
------------------------------ ------------------- ----------
SDP_PM JAVA CLASS 1
SDP_PM JAVA SOURCE 1
SDP_PM PROCEDURE 3
SDPSDI VIEW 1
SDPNSI VIEW 7
WANGYONG PROCEDURE 2
SDPRPI SYNONYM 6
SDPSDI SYNONYM 12
SDPRPI VIEW 3
SDPNSI SYNONYM 6
SDP_SMECD PROCEDURE 2
11 rows selected.
A. 编译procedure、function、view、package和materialized view
编译多数对象都能使用如下句型完成,注意package需要编译body:
alter procedure
alter function
alter view
alter package
alter package
alter materialized view
alter trigger
alter synonym
目前失效的对象类型procedure、view和synonym有生成重新编译的sql脚本
set heading off
spool compileinvalid.sql
select 'alter '||object_type|| ' ' || owner ||'.'||object_name || ' compile;' from dba_objects where status='INVALID' and object_type in('PROCEDURE', 'VIEW', 'SYNONYM') and OWNER in ('SDP_PM','SDP_SMECD','SDPNSI','SDPRPI',
'SDPSDI', 'SDP_USP', 'SDP_USM', 'SDP_MISS');
spool off
sys用户运行compileinvalid.sql脚本
再次执行之前sql,检查结果
alter VIEW SDPNSI.V_USER_VOD_STAT compile;
alter VIEW SDPNSI.V_USER_CHANNEL_SHIFT compile;
alter VIEW SDPNSI.V_SERVICE_RESOURCE compile;
alter VIEW SDPNSI.V_SERVICE_RECORD compile;
alter VIEW SDPNSI.V_PROD_SERVICE compile;
alter VIEW SDPNSI.V_PROD compile;
alter VIEW SDPNSI.V_ASSET_TYPE compile;
alter VIEW SDPRPI.V_VODCLICKCOUNT compile;
alter VIEW SDPRPI.V_SERVICE_USAGE_AMOUNT compile;
alter VIEW SDPRPI.V_CDR compile;
alter VIEW SDPSDI.V_REDIRECT compile;
alter PROCEDURE SDP_PM.UP_SYS_IEPG_CONTENT_IDX compile;
alter PROCEDURE SDP_PM.TV_PROGRAM_HITS_STATISTICS compile;
alter PROCEDURE SDP_PM.PROC_TV_PROGRAM_HITS compile;
alter PROCEDURE SDP_PM.DEL_T_REDIRECT_RECORD compile;
alter PROCEDURE SDP_SMECD.T_OTT_ACOUNT_ADD_PASSWD compile;
alter PROCEDURE SDP_SMECD.EXT_SUB_UPDATE compile;
仍然有17个对象没有编译成功。
使用如下命令查看错误
SQL> col owner for a10
SQL> col name for a30
SQL> col type for a10
SQL> col text for a80
SQL> set linesize 150
SQL> set pagesize 0
SQL> select owner, name, type, substr(text,0,60) text from dba_errors WHERE OWNER in ('SDP_PM','SDP_SMECD','SDPNSI','SDPRPI',
'SDPSDI', 'SDP_USP', 'SDP_USM', 'SDP_MISS');
对其逐个分析:
SDPNSI.V_USER_VOD_STAT
定义:
CREATE OR REPLACE VIEW V_USER_VOD_STAT AS
SELECT
T.USER_ID USERID,-- 用户标识
T.RESOURCE_ID,-- 内容ID
1 VODCOUNT,-- 次数
CREATE_TIME -- 时间范围(创建时间)
FROM
T_IEPG_SESSION T
WHERE
tryFlag = 0 --- Not test;
原因:
T_IEPG_SESSION T同义词引用SDP_PORTAL_ASYNC.T_IEPG_SESSION;但是SDP_PORTAL_ASYNC用户不存在,故不需要做处理。
SDPNSI.V_USER_CHANNEL_SHIFT
定义:
CREATE OR REPLACE VIEW V_USER_CHANNEL_SHIFT AS
SELECT
T3.USER_CODE USERID, -- 用户标识
T2.RESOURCE_ID, -- 频道编号
T2.CHANNEL_NAME, -- 频道名称
to_date('1970-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') + T.POSTTIME /24/3600 POST_TIME -- 切换时间
FROM
T_TV_PROGRAM T, T_IEPG_CHANNEL T2, T_USER T3
WHERE
T.SERVICESID = T2.SERVICEID
AND T.TSID = T2.TS_ID
AND T.SMARTCARDID = T3.SMARTCARD_ID;
原因:
T_TV_PROGRAM是同义词,引用SDP_PM.T_TV_PROGRAM表,sdp_pm用户不存在此表,故视图无效。不需要处理
SDPNSI.V_SERVICE_RESOURCE
定义:
CREATE OR REPLACE VIEW V_SERVICE_RESOURCE AS
SELECT
T.PROD_SPEC_ID SERVICE_ID,-- 业务ID
T.Resource_ID RESOURCE_ID -- 内容ID
FROM
T_PROD_RESOURCE T;
原因:
T_PROD_RESOURCE是同义词,引用SDP_SMEMD.T_PROD_RESOURCE,此表不存在,故视图无效。不需要处理。
SDPNSI.V_SERVICE_RECORD
定义:
CREATE OR REPLACE VIEW V_SERVICE_RECORD AS
SELECT
T.USER_ID USER_CODE, -- 用户标识
T2.PRODOFFERING_CODE PRODUCT_CODE, -- 产品ID
T.RESOURCE_ID, -- 内容ID
T2.PRODOFFERING_NAME PRODUCT_NAME, -- 产品名称
T.PROGRAM_START_TIME START_TIME, -- 开始时间
T.PROGRAM_START_TIME + (T4.PLAY_TIME/3600/24 ) END_TIME ---- CEIL(DBMS_RANDOM.value(25,144))/3600 -- 结束时间
FROM
T_IEPG_SESSION T,T_PRODOFFERING T2, T_USERINFO T3 ,T_IEPG_ASSET_FILE T4
WHERE
T.PRODOFFERING_ID = T2.PRODOFFERING_ID
AND T.USER_ID = T3.USER_ID
AND T.RESOURCE_ID = T4.RESOURCE_ID;
原因:
与SDPNSI.V_USER_VOD_STAT视图失败的原因相同。
SDPNSI.V_PROD_SERVICE
定义:
CREATE OR REPLACE VIEW V_PROD_SERVICE AS
SELECT
T.PRODSPEC_ID SERVICE_ID, -- 业务ID
T.PRODOFFERING_CODE PRODUCT_CODE -- 产品ID
FROM
T_PRODUCTOFFERING T;
原因:
T_PRODOFFERING是SDP_PM.T_PRODOFFERING的同义词,但是SDP_PM.T_PRODOFFERING表不存在,故视图无效。
SDPNSI.V_PROD
定义:
CREATE OR REPLACE VIEW V_PROD AS
SELECT
PRODOFFERING_CODE PRODUCT_CODE, -- 产品ID
PRODORFERING_NAME PRODUCT_NAME, -- 产品名称
STATUS, -- 状态
OFFLINE_TIME - 7 CREATE_TIME, -- 创建日期
ONLINE_TIME EFFECTIVE_TIME, -- 受理生效时间
OFFLINE_TIME EXPIRE_TIME, -- 受理失效时间
'' PROVIDER_CODE -- 提供者(SP编码)
FROM T_PRODUCTOFFERING;
原因:
T_PRODOFFERING是SDP_PM.T_PRODOFFERING的同义词,但是SDP_PM.T_PRODOFFERING表不存在,故视图无效。
SDPNSI.V_ASSET_TYPE
定义:
CREATE OR REPLACE VIEW V_ASSET_TYPE AS
SELECT
T.ASSET_TYPE_ID ,-- 分类ID
T.ASSET_TYPE ,--分类名称
T.PARENT_ID --所属父分类
FROM
T_Asset_Type T;
原因:
T_ASSET_TYPE是SDP_CMS.T_ASSET_TYPE的同义词,但是SDP_CMS模式不存在,故不处理。
SDPRPI.V_VODCLICKCOUNT
定义:
create or replace view v_vodclickcount as
select trunc(a.create_time) create_date,a.resource_id,a.resource_name,count(a.user_code) as times,b.asset_code,c.boss_areacode as city_code
from (select * from t_iepg_session@sdp_portal_async
where create_time>=to_date(to_char(sysdate-1,'yyyy-mm-dd')||' 00:00:00','yyyy-mm-dd hh24:mi:ss')
and create_time
sdp_pm.t_iepg_asset_file b,t_user c
where a.resource_id=b.resource_id and a.user_code=c.user_id
group by trunc(a.create_time ),a.resource_id,a.resource_name ,b.asset_code,c.boss_areacode;
原因:
引用t_iepg_session@sdp_portal_async,由于DBLINK sdp_portal_async网络超时,故此视图失败。开通网络之后,执行成功。
SDPRPI.V_SERVICE_USAGE_AMOUNT
定义:
create or replace view v_service_usage_amount as
select
t1.record_id , --业务使用流水号
t1.update_time update_time, --业务使用时间
t1.user_code , --用户编号
t1.service_code , --业务编号
t1.service_name , --业务名称
t1.spcode , --SP编号
t2.fullname --SP名称
from t_redirect_record@SDP_PORTAL_ASYNC_A t1,t_iepg_provider t2
where t1.spcode = t2.provider_code
and t1.error_code = 0
and t1.user_code is not null;
原因:
引用DBLINK,需要创建DBLINK SDP_PORTAL_ASYNC_A。
SDPRPI.V_CDR
定义:
create or replace view v_cdr as
select a.resource_id as CDR_ID,a.user_code,''as CDR_TYPE,''as PRODUCT_CODE,'' as PRODUCT_NAME,b.asset_code as RESOURCE_ID,a.resource_name ,
''as SESSION_ID,a.create_time as START_TIME,a.create_time as END_TIME,'' as BEGIN_POSITION,'' as END_POSITION,
'' as RESULT_CODE,'' as RESULT_DESC,a.create_time,'' as SUB_ID, '' as MM, '' as DD, '' as PRICE,
'' as AMOUNT,'' as AUTH_TOKEN,0 as FEE_TYPE,'' as PLAY_PATH,'' as SP_CODE,
c.boss_areacode as CITY_CODE,'' as ASSET_ID,'' as ROW_ID,
'' as EPG_START_TIME,'' as EPG_END_TIME,'' as IS_PERVIEW,'' as BUSINESS_TYPE,'' as STATUS,'' as PROGRAM_PATH,
'' ASSET_INDEX,''ASSET_END_POSITION,''as PURCHASETOKEN,c.boss_areacode as AREACODE from t_iepg_session@sdp_portal_async a,
sdp_pm.t_iepg_asset_file b,t_user c
where a.resource_id=b.resource_id and a.user_code=c.user_id;
原因:
引用DBLINK,需要创建sdp_portal_async
SDPSDI.V_REDIRECT
定义:
CREATE OR REPLACE VIEW V_REDIRECT AS
SELECT
t.spcode as spCode,
t.service_code as serviceCode,
t.update_time as updateTime
FROM
SDP_PORTAL_ASYNC.t_redirect_record t
WHERE t.update_time >= to_date(to_char(sysdate - 2 ,'yyyyMMdd'),'yyyyMMddhh24miss')
and t.update_time < to_date(to_char(sysdate - 1,'yyyyMMdd'),'yyyyMMddhh24miss')
and t.user_code != '123456';
原因:
引用SDP_PORTAL_ASYNC模式,导入时没有此模式。
SDP_PM.UP_SYS_IEPG_CONTENT_IDX
定义:
CREATE OR REPLACE PROCEDURE "UP_SYS_IEPG_CONTENT_IDX" as
BEGIN
---- /* sync index list: */
ctx_ddl.SYNC_INDEX('FIX_IEPG_ASSET_FILE0');
………………………………………………………………………
原因:
权限不足。使用如下语句授予权限grant execute on ctxsys.ctx_ddl to sdp_pm;
重新编译即可成功。
SDP_PM.TV_PROGRAM_HITS_STATISTICS
定义:
CREATE OR REPLACE PROCEDURE "TV_PROGRAM_HITS_STATISTICS"
AS
/**
-- 1. modify 7.13
*/
--记录当前时间单位为秒
nowdate number(13);
BEGIN
--查询当前时间单位为秒
select
to_number(to_date(to_char(sysdate,'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') -to_date('1970-01-01 8:0:0', 'YYYY-MM-DD HH24:MI:SS')) * 24 * 60 * 60
into nowdate from dual;
update t_Tv_Program t set t.isstatistics = 1;
……………………………………
原因:
引用t_Tv_Program,sdp_pm.t_Tv_Program表不存在
SDP_PM.PROC_TV_PROGRAM_HITS
定义:
CREATE OR REPLACE PROCEDURE "TV_PROGRAM_HITS_STATISTICS"
AS
/**
-- 1. modify 7.13
*/
--记录当前时间单位为秒
nowdate number(13);
BEGIN
--查询当前时间单位为秒
select
to_number(to_date(to_char(sysdate,'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') -to_date('1970-01-01 8:0:0', 'YYYY-MM-DD HH24:MI:SS')) * 24 * 60 * 60
into nowdate from dual;
update t_Tv_Program t set t.isstatistics = 1;
………………………………
原因:
引用t_tv_program,t_tv_program表不存在,故存储过程编译失败。
SDP_PM.DEL_T_REDIRECT_RECORD
定义:
CREATE OR REPLACE PROCEDURE "DEL_T_REDIRECT_RECORD" AS
/**
* 删除监控系统发送过来的跳转记录
*/
BEGIN
delete from t_redirect_record t where user_code='100250258' and update_time>sysdate-2;
COMMIT;
END;
原因:
引用t_redirect_record,t_redirect_record表不存在,故存储过程失败。
SDP_SMECD.T_OTT_ACOUNT_ADD_PASSWD
定义:
CREATE OR REPLACE PROCEDURE "T_OTT_ACOUNT_ADD_PASSWD"
AS
BEGIN
update t_ott_acount oa
set password = nvl((select ext.password
from t_user_ext_info ext
where ext.cert_code = oa.device_id
and rownum = 1),
oa.password)
where user_name in (select cert_code from TMP_PW);
commit;
end T_OTT_ACOUNT_ADD_PASSWD;
原因:
引用cert_code,但是cert_code不存在
SDP_SMECD.EXT_SUB_UPDATE
定义:
原因:
存储过程中引用t_user_update_9999999,t_user_update_9999999不存在。
B. 编译JAVA SOURCE和JAVA CLASS
编译JAVA SOURCE和JAVA CLASS的句型:
ALTER JAVA CLASS "" RESOLVE;
ALTER JAVA SOURCE "" RESOLVE;
生成重新编译的sql脚本
set heading off
spool compileinvalid.sql
select 'alter '||object_type|| ' ' || owner ||'.'||object_name || ' resolve;' from dba_objects where status='INVALID' and object_type in('JAVA CLASS', 'JAVA SOURCE');
spool off
SQL> ALTER JAVA CLASS SDP_PM.mcp2BossUserInfo RESOLVE;
SQL> ALTER JAVA SOURCE SDP_PM.mcp2boss RESOLVE;
尝试失败。报对象不存在。
调用
exec dbms_utility.compile_schema('SDP_PM');
或者
SQL> exec utl_recomp.recomp_serial ();
两种方法,都能够将Java源和类重新成功编译。
如果权限没有问题,同义词引用的表是否存在,状态都正常;
数据迁移之后,要检查无效对象,需要与应用开发人员多沟通,确认无效对象是否正常;
如果存在public的对象,使用用户模式导出时,需要重新创建public对象;
重新编译java源和类,使用exec dbms_utility.compile_schema('SDP_PM');或者exec utl_recomp.recomp_serial ();
参考:Debug and Validate Invalid Objects (文档 ID 300056.1)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31142205/viewspace-2120529/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31142205/viewspace-2120529/