防止 SQL*Plus 从变量的字符串值中间删除空格
Prevent SQL*Plus from removing spaces from middle of variable's string value
我有一份 SQL*Plus 报告需要其运行时格式为“MM/DD/YYYY hh24:mi”打印在每页的标题部分。所以我做了以下事情:
-- set variable run_time
column rTime new_value run_time noprint
select to_char(sysdate,'MM/DD/YYYY hh24:mi') rTime from dual;
-- print contents
ttitle right 'RUN TIME: ' &run_time
但是打印出来的是日期和时间,中间没有space,像这样:
运行 日期:04/07/202115:32
起初我认为这可能与日期到字符的转换有关,但它与任何字符串都是相同的问题并且没有涉及日期。例如:
column testing new_value testing123 noprint
select 'blah blah' testing from dual;
ttitle left &testing123
结果是“blahblah”。所以中间的 space 再次被丢弃。有谁知道如何防止这种行为?是否有需要设置的 SQL*Plus 设置,或者我需要在“列”或 ttitle 部分中设置格式的内容?
Enter text in single quotes if you want to place more than one word on a single line.
就像他们的例子一样,把变量放在单引号里;也是:
ttitle left '&testing123'
或
ttitle right 'RUN TIME: &run_time'
我有一份 SQL*Plus 报告需要其运行时格式为“MM/DD/YYYY hh24:mi”打印在每页的标题部分。所以我做了以下事情:
-- set variable run_time
column rTime new_value run_time noprint
select to_char(sysdate,'MM/DD/YYYY hh24:mi') rTime from dual;
-- print contents
ttitle right 'RUN TIME: ' &run_time
但是打印出来的是日期和时间,中间没有space,像这样:
运行 日期:04/07/202115:32
起初我认为这可能与日期到字符的转换有关,但它与任何字符串都是相同的问题并且没有涉及日期。例如:
column testing new_value testing123 noprint
select 'blah blah' testing from dual;
ttitle left &testing123
结果是“blahblah”。所以中间的 space 再次被丢弃。有谁知道如何防止这种行为?是否有需要设置的 SQL*Plus 设置,或者我需要在“列”或 ttitle 部分中设置格式的内容?
Enter text in single quotes if you want to place more than one word on a single line.
就像他们的例子一样,把变量放在单引号里;也是:
ttitle left '&testing123'
或
ttitle right 'RUN TIME: &run_time'