[20240917]tpt pr.sql脚本小问题.txt

来源:这里教程网 时间:2026-03-03 20:35:26 作者:

[20240917]tpt pr.sql脚本小问题.txt --//执行pr.sql后会在tpt/tmp目录就下set_book-20240917-105533.sql这类的文件,平时需要清理。 --//主要问题是@@saveset,保存配置在tpt/tmp,执行完成后使用@@loadset加载,但是最后没有删除。 --//可以定义def _set_tmpfile=&_tpt_tempdir/set_&_tpt_tempfile..sql,结尾增加 --//host &_delete &_set_tmpfile. --//注:^F 在vim下使用ctrl+v ctrl+f输入在linux下。实际上是chr(6),这样不会与其他字符相互冲突。在windows下按ctrl+q ctrl+f --//输入。 $ cat -v tpt/pr.sql . -- Notes:   This script is based on Tom Kyte's original printtbl code ( http://asktom.oracle.com ) --          For coding simplicity (read: lazyness) I'm using custom quotation marks ( q'\ ) so --          this script works only from Oracle 10gR2 onwards def _pr_tmpfile=&_tpt_tempdir/pr_&_tpt_tempfile..tmp def _set_tmpfile=&_tpt_tempdir/set_&_tpt_tempfile..sql @@saveset set serverout on size 1000000 termout off save &_pr_tmpfile replace set termout on 0 c clob := q'^F 0 declare 999999      ^F';; 999999      l_theCursor     integer default dbms_sql.open_cursor;; 999999      l_columnValue   varchar2(4000);; 999999      l_status        integer;; 999999      l_descTbl       dbms_sql.desc_tab;; 999999      l_colCnt        number;; 999999  begin 999999      dbms_sql.parse(  l_theCursor, c, dbms_sql.native );; 999999      dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl );; 999999      for i in 1 .. l_colCnt loop 999999          dbms_sql.define_column( l_theCursor, i, 999999                                  l_columnValue, 4000 );; 999999      end loop;; 999999      l_status := dbms_sql.execute(l_theCursor);; 999999      while ( dbms_sql.fetch_rows(l_theCursor) > 0 ) loop 999999          dbms_output.put_line( '==============================' );; 999999          for i in 1 .. l_colCnt loop 999999                  dbms_sql.column_value( l_theCursor, i, 999999                                         l_columnValue );; 999999                  dbms_output.put_line 999999                      ( rpad( l_descTbl(i).col_name, 999999                        30 ) || ': ' || l_columnValue );; 999999          end loop;; 999999      end loop;; 999999  exception 999999      when others then 999999          dbms_output.put_line(dbms_utility.format_error_backtrace);; 999999          raise;; 999999 end;; / @@loadset get &_pr_tmpfile nolist host &_delete &_pr_tmpfile &_delete &_set_tmpfile --//不过麻烦的是作者还有一些脚本也是调用saveset,而没有做清除操作。 $ grep saveset *.sql desc.sql:@@saveset dsv.sql:@@saveset getplusparm.sql:@saveset lastchanged.sql:@@saveset nonsharedsum.sql:@@saveset oerr.sql:@@saveset pr2.sql:@@saveset prc.sql:@@saveset printtab2.sql:@@saveset prq.sql:@@saveset prr.sql:@@saveset pr.sql:@@saveset prs.sql:@@saveset ti.sql:@@saveset tsv.sql:@@saveset utopsql.sql:@@saveset --//其他程序改动太大,还是自己以后到一定时间手工清理了。

相关推荐