+ -
当前位置:首页 → 问答吧 → 如何屏蔽掉屏幕输出

如何屏蔽掉屏幕输出

时间:2011-09-11

来源:互联网

代码如下:
accept sql_id -
prompt 'Enter value for sql_id: ' -
default 'X0X0X0X0'
accept hint_txt -
prompt 'Enter value for hint_text: ' -
default 'comment'


set feedback off
set sqlblanklines on
set serveroutput on

declare
l_profile_name varchar2(30);
cl_sql_text clob;
begin

select
sql_fulltext
into
cl_sql_text
from
v$sqlarea
where
sql_id = '&&sql_id';


select 'PROFILE'||'&&sql_id'||'_MANUAL'
into l_profile_name
from dual;

dbms_sqltune.import_sql_profile(
sql_text => cl_sql_text,
profile => sqlprof_attr(q'[&&hint_txt]'),
category => '',
name => l_profile_name,
force_match =>FALSE
);

dbms_output.put_line(' ');
dbms_output.put_line('Profile '||l_profile_name||' created.');
dbms_output.put_line(' ');

EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line(' ');
dbms_output.put_line('ERROR: SQL_ID: '||'&&sql_id'||' does not exist in v$sqlarea.');
dbms_output.put_line('The SQL statement must be in the shared pool to use this script.');
dbms_output.put_line(' ');
end;
/

undef sql_id
undef hint_txt

set sqlblanklines off
set feedback on







运行效果如下:
SQL> @text
Enter value for sql_id: 9jnx2cjukjtu7
Enter value for hint_text: no_index(@"SEL$1" "WXH_TBD"@"SEL$1" WW)
old  13: sql_id = '&&sql_id';
new  13: sql_id = '9jnx2cjukjtu7';
old  15: select 'PROFILE'||'&&sql_id'||'_MANUAL'
new  15: select 'PROFILE'||'9jnx2cjukjtu7'||'_MANUAL'
old  21: profile => sqlprof_attr(q'[&&hint_txt]'),
new  21: profile => sqlprof_attr(q'[no_index(@"SEL$1" "WXH_TBD"@"SEL$1" WW)]'),
old  34: dbms_output.put_line('ERROR: SQL_ID: '||'&&sql_id'||' does not exist in v$sqlarea.');
new  34: dbms_output.put_line('ERROR: SQL_ID: '||'9jnx2cjukjtu7'||' does not exist in v$sqlarea.');
Profile PROFILE9jnx2cjukjtu7_MANUAL created.



我想屏幕掉这种old  13: sql_id = '&&sql_id';new  13: sql_id = '9jnx2cjukjtu7';东东,但是还想dbms_output.put_line能够输出内容,该怎么办?
如果是set term off,就什么内容都输出不了了。
我指向这些old,new之类的东东不要输出来了

作者: 贪婪的猪   发布时间: 2011-09-11

set verify off

作者: mkstone   发布时间: 2011-09-12