如何屏蔽掉屏幕输出
时间: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之类的东东不要输出来了
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
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28