批次過程獲取指令碼
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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Universal-Image-Loader原始碼解解析---display過程 + 獲取bitmap過程原始碼
- jenkins pipline指令碼 獲取git分支Jenkins指令碼Git
- Go使用協程批次獲取資料,加快介面返回速度Go
- 常用指令碼:獲取隱含引數指令碼
- Spring原始碼剖析4:其餘方式獲取Bean的過程分析Spring原始碼Bean
- 批次解壓shell指令碼指令碼
- shell指令碼獲取函式返回值指令碼函式
- shell指令碼獲取時間格式化指令碼
- 獲取sql完整指令碼,get_fulltext.shSQL指令碼
- Powershell 如何批次獲取檔案大小的實現程式碼
- PostgreSQL獲取建表語句儲存過程SQL儲存過程
- Linux c程式中獲取shell指令碼輸出(如獲取system命令輸出)LinuxC程式指令碼
- Spring原始碼剖析4:懶載入的單例Bean獲取過程分析Spring原始碼單例Bean
- 【Redis】獲取沒有設定ttl的key指令碼Redis指令碼
- vbs指令碼獲取Am註冊路徑資訊指令碼
- 獲取AWR的指令碼,可以在crontab裡面部署指令碼
- loadrunner12.6快速實戰之透過抓包來獲取app測試指令碼APP指令碼
- 透過硬體識別符號獲取過程映像輸入符號
- shell指令碼之批次清空檔案指令碼
- python指令碼批次建立資料表Python指令碼
- Oracle批次生成Merge指令碼程式Oracle指令碼
- 指令的執行過程
- 線上定時指令碼執行慢,分析過程指令碼
- sqlserver資料庫還原儲存過程指令碼SQLServer資料庫儲存過程指令碼
- mysql 儲存過程 procedure 批次建表MySql儲存過程
- JavaScript指令碼批次取消抖音喜歡JavaScript指令碼
- shell指令碼:批次傳送curl請求指令碼
- shell指令碼中main函式中$#獲取不到指令碼傳入引數個數淺析指令碼AI函式
- Linux Shell獲取正在執行指令碼的絕對路徑Linux指令碼
- Python指令碼的常見引數獲取和處理方式Python指令碼
- memcahed 的 python sdk 如何批次獲取memcahed的keyPython
- 根據key集合批次從map中獲取value
- Bash 指令碼例項:獲取符號連結的目標位置指令碼符號
- 如何簡單快捷批次獲取店鋪的所有商品?
- 【Excel】Excel 拆分以及批次匯入指令碼開發Excel指令碼
- JS指令碼批次處理TS資料型別JS指令碼資料型別
- 批次非同步上傳aws圖片指令碼(python)非同步指令碼Python
- 【Azure Redis 快取】使用Python程式碼獲取Azure Redis的監控指標值 (含Powershell指令碼方式)Redis快取Python指標指令碼
- ES系列(五):獲取單條資料get處理過程實現