5、使用new_value子句
SQL> col ename new_value v_name -->new_value的实质是将得到的结果赋值给v_name以便后续调用
SQL> select ename from emp where empno=7788;
ENAME
----------
SCOTT
SQL> select ename,job,sal from emp where ename='&v_name';
old 1: select ename,job,sal from emp where ename='&v_name'
new 1: select ename,job,sal from emp where ename='SCOTT'
ENAME JOB SAL
---------- --------- ----------
SCOTT ANALYST 3000
--交互式方式使用new_value --Author : Robinson Cheng
--下面的脚本是从awrrpti.sql摘取部分片段来展示 --Blog : http://www.linuxidc.com
[Oracle@linux1 ~]$ more temp.sql
prompt
prompt Specify the Report Type
prompt ~~~~~~~~~~~~~~~~~~~~~~~
prompt Would you like an HTML report, or a plain text report?
prompt Enter 'html' for an HTML report, or 'text' for plain text
prompt Defaults to 'html'
column report_type new_value report_type; -->这个地方定义的new_value是关键
set heading off;
select 'Type Specified: ',lower(nvl('&&report_type','html')) report_type from dual;
set heading on;
prompt "Variable report_type value is :&report_type"
SQL> @temp.sql -->执行时出现交互提示
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Would you like an HTML report, or a plain text report?
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'
Enter value for report_type: html
old 1: select 'Type Specified: ',lower(nvl('&&report_type','html')) report_type from dual
new 1: select 'Type Specified: ',lower(nvl('html','html')) report_type from dual
Type Specified: html
"Variable report_type value is :html" -->变量的值传递给了report_type
