为什么 sqlplus 变量在句点上表现得很好笑?
why do sqlplus variables act funny with a period?
为什么 sqplus 变量在尝试在其后使用句点时表现得很滑稽?
SQL> set define on
SQL> accept goo char prompt 'goo: ';
goo: mygoo
SQL> select '&goo' from dual;
old 1: select '&goo' from dual
new 1: select 'mygoo' from dual
MYGO
-----
mygoo
SQL> select '&goo something' from dual;
old 1: select '&goo something' from dual
new 1: select 'mygoo something' from dual
MYGOOSOMETHING
---------------
mygoo something
SQL> select '&goo.something' from dual;
old 1: select '&goo.something' from dual
new 1: select 'mygoosomething' from dual
MYGOOSOMETHIN
--------------
mygoosomething
SQL> select '&goo..something' from dual;
old 1: select '&goo..something' from dual
new 1: select 'mygoo.something' from dual
MYGOO.SOMETHIN
---------------
mygoo.something
为什么我必须加倍来月经?有没有更好的方法?
这根本有趣,但这是预期的默认行为。
SET CONCAT
字符是句点(除非您将其设置为其他字符)。如果要在替换变量之后添加一个句点,则必须使用两个连续的句点。
如果您将连接字符设置为例如#
,然后周期行为正常:
SQL> set concat '#'
SQL> select '&goo.' from dual;
old 1: select '&goo.' from dual
new 1: select 'mygoo.' from dual
'MYGOO
------
mygoo.
如果您将其设置回句号,它又会表现得有趣:
SQL> set concat '.'
SQL> select '&goo.' from dual;
old 1: select '&goo.' from dual
new 1: select 'mygoo' from dual
'MYGO
-----
mygoo
SQL> select '&goo..' from dual;
old 1: select '&goo..' from dual
new 1: select 'mygoo.' from dual
'MYGOO
------
mygoo.
最后,回到#
,它也表现得有趣,你必须使用其中两个:
SQL> set concat '#'
SQL> select '&goo#' from dual;
old 1: select '&goo#' from dual
new 1: select 'mygoo' from dual
'MYGO
-----
mygoo
SQL> select '&goo##' from dual;
old 1: select '&goo##' from dual
new 1: select 'mygoo#' from dual
'MYGOO
------
mygoo#
SQL>
为什么 sqplus 变量在尝试在其后使用句点时表现得很滑稽?
SQL> set define on
SQL> accept goo char prompt 'goo: ';
goo: mygoo
SQL> select '&goo' from dual;
old 1: select '&goo' from dual
new 1: select 'mygoo' from dual
MYGO
-----
mygoo
SQL> select '&goo something' from dual;
old 1: select '&goo something' from dual
new 1: select 'mygoo something' from dual
MYGOOSOMETHING
---------------
mygoo something
SQL> select '&goo.something' from dual;
old 1: select '&goo.something' from dual
new 1: select 'mygoosomething' from dual
MYGOOSOMETHIN
--------------
mygoosomething
SQL> select '&goo..something' from dual;
old 1: select '&goo..something' from dual
new 1: select 'mygoo.something' from dual
MYGOO.SOMETHIN
---------------
mygoo.something
为什么我必须加倍来月经?有没有更好的方法?
这根本有趣,但这是预期的默认行为。
SET CONCAT
字符是句点(除非您将其设置为其他字符)。如果要在替换变量之后添加一个句点,则必须使用两个连续的句点。
如果您将连接字符设置为例如#
,然后周期行为正常:
SQL> set concat '#'
SQL> select '&goo.' from dual;
old 1: select '&goo.' from dual
new 1: select 'mygoo.' from dual
'MYGOO
------
mygoo.
如果您将其设置回句号,它又会表现得有趣:
SQL> set concat '.'
SQL> select '&goo.' from dual;
old 1: select '&goo.' from dual
new 1: select 'mygoo' from dual
'MYGO
-----
mygoo
SQL> select '&goo..' from dual;
old 1: select '&goo..' from dual
new 1: select 'mygoo.' from dual
'MYGOO
------
mygoo.
最后,回到#
,它也表现得有趣,你必须使用其中两个:
SQL> set concat '#'
SQL> select '&goo#' from dual;
old 1: select '&goo#' from dual
new 1: select 'mygoo' from dual
'MYGO
-----
mygoo
SQL> select '&goo##' from dual;
old 1: select '&goo##' from dual
new 1: select 'mygoo#' from dual
'MYGOO
------
mygoo#
SQL>