批次過程獲取指令碼
declare
v_text varchar2(4000);
v_line number;
v_max_line number;
v_owner varchar2(30);
v_name varchar2(30);
v_type varchar2(12);
-- i_owner varchar2(30);
-- i_object varchar2(30);
cursor c_xo is
select distinct xo.owner,xo.name,xo.type from ALL_SOURCE xo
where --(xo.bbbz like '1%' or xo.bbbz like '2%') and
xo.owner='&J1_G3_ZBQ' and xo.type in ('PROCEDURE','PACKAGE','PACKAGE BODY','FUNCTION') ORDER BY TYPE;
cursor c_as is
select line,case when line=1 then 'create or replace '||text
else text
end text
from all_source where owner=v_owner and name =v_name and type =v_type;
fhandle utl_file.file_type;
begin
--
for cur_1 in c_xo loop
v_owner :=cur_1.owner;
v_name :=cur_1.name;
v_type :=cur_1.type;
fhandle := utl_file.fopen(v_owner||'_PROC_DIR','init-proc.sql', 'a');
if v_owner='J1_G3_ZBQ' then
--lvc_line := '@"01 dw\02 ldm\01 object\01 table\'||cur.table_name||'.sql";';
v_text := '@"01 dw\01 inf\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_LDM' then
v_text := '@"01 dw\02 ldm\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_DW' then
v_text := '@"01 dw\03 dw\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_DI' then
v_text := '@"01 dw\05 di\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_CXTJ' then
v_text := '@"03 xt\01 cxtj\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_DMT' then
v_text := '@"03 xt\06 dmt\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_METAONE' then
v_text := '@"03 xt\07 metaone\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_LDCX' then
v_text := '@"01 dw\08 ldcx\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
end if;
--@"01 dw\02 ldm\01 object\01 table\ldmt02_jbxx_nsrckzhzhxx.sql";
utl_file.put_line(fhandle ,v_text);
utl_file.fclose(fhandle);
end loop;
--
for cur_0 in c_xo loop
v_owner :=cur_0.owner;
v_name :=cur_0.name;
v_type :=cur_0.type;
select max(line) into v_max_line from all_source where owner=v_owner and name =v_name and type =v_type;
-- dbms_output.put_line(v_owner||','||v_name||','||v_type);
fhandle := utl_file.fopen(v_owner||'_PROC_DIR',v_name||'_'||v_type||'.sql', 'w',32767);
utl_file.put_line(fhandle ,'prompt'||' '||v_type||' '||v_owner||'.'||v_name||' created');
utl_file.put_line(fhandle ,'set define off');
for cur in c_as loop
v_text :=cur.text;
v_line :=cur.line;
if v_line=v_max_line then
utl_file.put_line(fhandle ,replace(replace(replace(v_text,chr(10),'/'),';',';'||chr(10)||'/'),'//','/'));
-- dbms_output.put_line(replace(v_text,chr(10),'/'));
else
utl_file.put_line(fhandle ,replace(v_text,chr(10),''));
-- dbms_output.put_line(replace(v_text,chr(10),''));
end if;
end loop;
utl_file.put_line(fhandle ,'set define on');
utl_file.fclose(fhandle);
end loop;
end;
/
v_text varchar2(4000);
v_line number;
v_max_line number;
v_owner varchar2(30);
v_name varchar2(30);
v_type varchar2(12);
-- i_owner varchar2(30);
-- i_object varchar2(30);
cursor c_xo is
select distinct xo.owner,xo.name,xo.type from ALL_SOURCE xo
where --(xo.bbbz like '1%' or xo.bbbz like '2%') and
xo.owner='&J1_G3_ZBQ' and xo.type in ('PROCEDURE','PACKAGE','PACKAGE BODY','FUNCTION') ORDER BY TYPE;
cursor c_as is
select line,case when line=1 then 'create or replace '||text
else text
end text
from all_source where owner=v_owner and name =v_name and type =v_type;
fhandle utl_file.file_type;
begin
--
for cur_1 in c_xo loop
v_owner :=cur_1.owner;
v_name :=cur_1.name;
v_type :=cur_1.type;
fhandle := utl_file.fopen(v_owner||'_PROC_DIR','init-proc.sql', 'a');
if v_owner='J1_G3_ZBQ' then
--lvc_line := '@"01 dw\02 ldm\01 object\01 table\'||cur.table_name||'.sql";';
v_text := '@"01 dw\01 inf\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_LDM' then
v_text := '@"01 dw\02 ldm\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_DW' then
v_text := '@"01 dw\03 dw\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_DI' then
v_text := '@"01 dw\05 di\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_CXTJ' then
v_text := '@"03 xt\01 cxtj\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_DMT' then
v_text := '@"03 xt\06 dmt\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_METAONE' then
v_text := '@"03 xt\07 metaone\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
elsif v_owner='J1_LDCX' then
v_text := '@"01 dw\08 ldcx\01 object\04 procedure\'||v_name||'_'||v_type||'.sql";';
end if;
--@"01 dw\02 ldm\01 object\01 table\ldmt02_jbxx_nsrckzhzhxx.sql";
utl_file.put_line(fhandle ,v_text);
utl_file.fclose(fhandle);
end loop;
--
for cur_0 in c_xo loop
v_owner :=cur_0.owner;
v_name :=cur_0.name;
v_type :=cur_0.type;
select max(line) into v_max_line from all_source where owner=v_owner and name =v_name and type =v_type;
-- dbms_output.put_line(v_owner||','||v_name||','||v_type);
fhandle := utl_file.fopen(v_owner||'_PROC_DIR',v_name||'_'||v_type||'.sql', 'w',32767);
utl_file.put_line(fhandle ,'prompt'||' '||v_type||' '||v_owner||'.'||v_name||' created');
utl_file.put_line(fhandle ,'set define off');
for cur in c_as loop
v_text :=cur.text;
v_line :=cur.line;
if v_line=v_max_line then
utl_file.put_line(fhandle ,replace(replace(replace(v_text,chr(10),'/'),';',';'||chr(10)||'/'),'//','/'));
-- dbms_output.put_line(replace(v_text,chr(10),'/'));
else
utl_file.put_line(fhandle ,replace(v_text,chr(10),''));
-- dbms_output.put_line(replace(v_text,chr(10),''));
end if;
end loop;
utl_file.put_line(fhandle ,'set define on');
utl_file.fclose(fhandle);
end loop;
end;
/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29802484/viewspace-1767284/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 單個過程獲取指令碼指令碼
- 透過hostname獲取IP的perl指令碼指令碼
- oracle獲取ddl指令碼Oracle指令碼
- Universal-Image-Loader原始碼解解析---display過程 + 獲取bitmap過程原始碼
- DHCP獲取IP地址的過程
- Go使用協程批次獲取資料,加快介面返回速度Go
- 如何批次獲取google pagerankGo
- 批次殺程式指令碼指令碼
- 常用指令碼:獲取隱含引數指令碼
- Python 指令碼之獲取CPU資訊Python指令碼
- 獲取單個檢視DDL指令碼指令碼
- 在RFT中如何通過指令碼獲取已新增到某個指令碼中的測試物件?指令碼物件
- 批次解壓shell指令碼指令碼
- Powershell 如何批次獲取檔案大小的實現程式碼
- oracle 儲存過程批次提交Oracle儲存過程
- shell指令碼獲取時間格式化指令碼
- shell指令碼獲取函式返回值指令碼函式
- 獲取sql完整指令碼,get_fulltext.shSQL指令碼
- 儲存過程批量生成awr指令碼儲存過程指令碼
- 全表複製過程建立指令碼指令碼
- Spring原始碼剖析4:其餘方式獲取Bean的過程分析Spring原始碼Bean
- PostgreSQL獲取建表語句儲存過程SQL儲存過程
- shell中獲取儲存過程返回值儲存過程
- 儲存過程獲取表被引用的資訊儲存過程
- 批次kill session實現指令碼Session指令碼
- 批次加使用者指令碼指令碼
- 透過oracle的指令碼研究其建庫過程Oracle指令碼
- 通過oracle的指令碼研究其建庫過程Oracle指令碼
- vbs指令碼獲取Am註冊路徑資訊指令碼
- 獲取完整的sqltext指令碼。get_fulltext.shSQL指令碼
- 獲取linux伺服器基本資訊指令碼Linux伺服器指令碼
- 指令碼:獲取當前的User Trace檔案指令碼
- jenkins pipline指令碼 獲取git分支Jenkins指令碼Git
- .NET用使用儲存過程獲取輸出引數的程式碼示例!儲存過程
- 見過最全的獲取資料庫資訊的指令碼--生成html的報告資料庫指令碼HTML
- 獲取某庫某個儲存過程內容儲存過程
- 透過硬體識別符號獲取過程映像輸入符號
- 資料庫批次授權指令碼資料庫指令碼