标签:
create table CUX_PKG_COPY
(
copy_id NUMBER,
pkg_name VARCHAR2(30 ),
copy_date DATE,
type VARCHAR2(30 ),
pkg_txt CLOB
);
create sequence CUX_PKG_COPY_S start with 1;
|
create or replace procedure copy_pkg(p_pkg_name varchar2 )
/*************************************************
-- Author : zhengxu7493
-- Created : 2016-10-04 12:15:37
-- Project : 蓝色光标财务一体化项目
-- Purpose : 同步一个包
-- 情 景 :
-- Parameters: parameter1 => 输入,
parameter2 => 输入,
parameter3 => 输入,
**************************************************/
is
v_txt clob;
v_pkg_name varchar2( 30) := p_pkg_name;
v_count number;
-- set serveroutput on;
v_id number;
begin
delete from cux_pkg_copy pc where pc.pkg_name=p_pkg_name;
v_id:=cux_pkg_copy_s.nextval;
v_count := 1;
for cur in (select us.TEXT
from us
where us.TYPE = ‘PACKAGE‘
and us.name = upper(v_pkg_name)
order by us.line asc) loop
if v_count = 1 then
v_txt := v_txt || ‘ create or replace ‘ || cur.text;
else
v_txt := v_txt || cur.text;
end if ;
v_count := v_count + 1;
end loop;
--v_txt:=v_txt||‘/‘||chr(13);
insert into cux_pkg_copy
(copy_id, pkg_name, copy_date, type, pkg_txt)
values
(cux_pkg_copy_s.nextval, p_pkg_name, sysdate, ‘PACKAGE‘ , v_txt);
v_txt := ‘‘;
v_count := 1;
for cur in (select us.TEXT
from us
where us.TYPE = ‘PACKAGE BODY‘
and us.name = upper(v_pkg_name)
order by us.line asc) loop
if v_count = 1 then
v_txt := v_txt || ‘ create or replace ‘ || cur.text;
else
v_txt := v_txt || cur.text;
end if ;
v_count := v_count + 1;
end loop;
--v_txt:=v_txt||‘/‘;
insert into cux_pkg_copy
(copy_id, pkg_name, copy_date, type, pkg_txt)
values
(cux_pkg_copy_s.nextval, p_pkg_name, sysdate, ‘PACKAGE BODY‘ , v_txt);
--p_copy_id:=v_id;
end;
|
create database link hec_test2uat2
connect to hecuat identified by hecuat
using ‘(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST= 192.168.203.25)(PORT=1521))
(CONNECT_DATA= (SERVICE_NAME=HECPROD)
(INSTANCE_NAME=HECPROD))
)‘;
create materialized view CUX_PKG_COPY_MV refresh complete on demand as select * from cux_pkg_copy@hec_test2uat2;
|
create or replace procedure sync_pkg(p_pkg varchar2 ) is
v1 number;
v_clob clob;
begin
copy_pkg@hec_test2uat2(p_pkg);
dbms_mview.refresh(list => ‘CUX_PKG_COPY_MV‘);
for cur in (select * from cux_pkg_copy_mv pc where pc.pkg_name = p_pkg) loop
select mv.pkg_txt into v_clob from cux_pkg_copy_mv mv where mv.copy_id=cur.copy_id;
execute immediate v_clob;
end loop;
end;
|
select uo.OBJECT_NAME, uo.OBJECT_TYPE
from user_objects uo
where uo.OBJECT_TYPE in (‘PACKAGE‘ , ‘PACKAGE BODY‘,‘TABLE‘,‘VIEW‘)
and uo.LAST_DDL_TIME > sysdate - 7
order by uo.LAST_DDL_TIME desc ;
如何使用这个方法呢?
在目标库
begin
sync_pkg(包名);
end;
|
标签:
原文地址:http://www.cnblogs.com/notfresh/p/5957414.html