[20220510]完善tpt expandz.sql指令碼.txt
[20220510]完善tpt expandz.sql指令碼.txt
--//以前改寫的版本,要求輸入引數2作為版本號.改為自動識別最佳.
$ cat tpt/expandz.sql
set long 40000
set serveroutput on
column arg new_value arg
set term off
select decode(&2,11,'sql2','utility') arg from dual;
set term on
prompt
declare
l_sqltext clob := null;
l_result clob := null;
begin
select sql_fulltext into l_sqltext from v$sqlarea where sql_id='&&1';
-- dbms_output.put_line(l_sqltext);
-- dbms_sql2.expand_sql_text(l_sqltext,l_result);
dbms_&arg..expand_sql_text(l_sqltext,l_result);
dbms_output.put_line(l_result);
end;
/
set serveroutput off
--//修改如下:
$ cat expandzz.sql
set long 40000
set serveroutput on
column arg new_value arg
define noprint='print'
set term off head off
col tpt_version_old &noprint new_value _tpt_version_old
col tpt_version_new &noprint new_value _tpt_version_new
col tpt_noprint &noprint new_value _tpt_noprint
WITH version AS (SELECT TO_NUMBER (SUBSTR (version, 1, 2)) v FROM v$instance)
SELECT CASE WHEN v <= 11 THEN '' ELSE '--' END tpt_version_old
,CASE WHEN v > 11 THEN '' ELSE '--' END tpt_version_new
FROM version;
set term on head on
prompt
declare
l_sqltext clob := null;
l_result clob := null;
begin
select sql_fulltext into l_sqltext from v$sqlarea where sql_id='&&1';
-- dbms_output.put_line(l_sqltext);
&&_tpt_version_old dbms_sql2.expand_sql_text(l_sqltext,l_result);
&&_tpt_version_new dbms_utility.expand_sql_text(l_sqltext,l_result);
dbms_output.put_line(l_result);
end;
/
set serveroutput off
--//仔細注意一個細節,必須先設定current_schema,不然報錯。
declare
*
ERROR at line 1:
ORA-24256: EXPAND_SQL_TEXT failed with ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_UTILITY", line 1568
ORA-06512: at line 8
> @ cs pppppp_hhh
alter session set current_schema=pppppp_hhh
Session altered.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2893857/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20220217]完善tpt gts.sql指令碼.txtSQL指令碼
- [20211129]完善tpt tablist.sql指令碼.txtSQL指令碼
- [20211130]完善tpt t.sql指令碼.txtSQL指令碼
- [20211129]完善tpt killi.sql指令碼.txtSQL指令碼
- [20211126]完善tpt pr.sql指令碼.txtSQL指令碼
- [20231025]完善tpt的trans.sql指令碼.txtSQL指令碼
- [20220111]完善tpt ashash_index_helper指令碼.txtIndex指令碼
- [20220323]完善tpt get_trace.sql指令碼.txtSQL指令碼
- [20220823]完善tpt的ashtop.sql指令碼.txtSQL指令碼
- [20220129]完善tpt ash ash_index_helperx指令碼.txtIndex指令碼
- [20230302]建立完善tpt o2.sql指令碼.txtSQL指令碼
- [20220519]完善tpt dash_wait_chains2.sql指令碼.txtAISQL指令碼
- [20220317]補充完善TPT 顯示欄位列的指令碼.txt指令碼
- [20220422]完善tpt ash ash_index_helperx指令碼2.txtIndex指令碼
- [20210506]完善tix指令碼.txt指令碼
- [20201202]完善sosi指令碼.txt指令碼
- [20211223]tpt ash ash_index_helperx指令碼.txtIndex指令碼
- [20210623]完善清除aud指令碼.txt指令碼
- [20240313]使用tpt ashtop.sql指令碼的困惑.txtSQL指令碼
- [20231117]完善ashtt.sql指令碼.txtSQL指令碼
- [20211230]完善sql_id指令碼.txtSQL指令碼
- [20211122]完善descx.sql指令碼.txtSQL指令碼
- [20221012]完善spsw.sql指令碼.txtSQL指令碼
- [20221010]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善gts.sql指令碼.txtSQL指令碼
- [20230203]完善awr.sql指令碼.txtSQL指令碼
- [20230123]完善curheapz.sql指令碼.txtSQL指令碼
- [20210407]完善ti.sql指令碼.txtSQL指令碼
- [20210125]完善hide.sql指令碼.txtIDESQL指令碼
- [20231101]使用tpt seg2.sql指令碼問題.txtSQL指令碼
- [20221126]tpt pr.sql指令碼執行問題.txtSQL指令碼
- [20191111]完善bind_cap.sql指令碼.txtSQL指令碼
- [20211202]完善d_buffer.sql指令碼.txtSQL指令碼
- [20230414]完善seg2.sql指令碼.txtSQL指令碼
- [20230210]建立完善swcnm.sql指令碼.txtSQL指令碼
- [20221208]完善bind_cap.sql指令碼.txtSQL指令碼
- [20220311]完善ash_wait_chains指令碼.txtAI指令碼