numeric column shows hex characters
Was doing a pivot report in SQL*Plus, counting number of records with status 'ERROR' and encounter hex values in the results. It can be reproduced on 11g using the following:
SQL> select 1 error from dual;
ERROR
----------
##########
Then I tested with a few variety:
SQL> select 1 errors from dual;
ERRORS
----------
1
SQL> select 'a' error from dual;
ERROR
-----------------------------------------------------------------
a
SQL> select 'a' errors from dual;
E
-
a
Seems like having a column named 'error' does weird stuffs to your result in SQL*Plus as this problem does not happen in SQL developer. Does anyone has an explanation? There seems no workaround except renaming it..
Looks like the NUMBER
format for column ERROR
is set by default in SQL*Plus
.
ATTRIBUTE
command shows the format of this.
SQL> attribute error
COLUMN ERROR ON
FORMAT A65
word_wrap
So, lets clear it.
SQL> column error clear
Now,
SQL> select 12 error from dual;
ERROR
----------
12
Full Script:
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 24 04:26:15 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> attribute error
COLUMN ERROR ON
FORMAT A65
word_wrap
SQL> show numwidth
numwidth 10
SQL> select 12 error from dual;
ERROR
----------
##########
SQL> column error clear
SQL> attribute error
SP2-0046: ATTRIBUTE 'error' not defined
SQL> select 12 error from dual;
ERROR
----------
12
SQL> column error format A10
SQL> select 12 error from dual;
ERROR
----------
##########
这只是一个workarround,但你可以把你的int作为char来转换。
SQL> select cast(1 as char(50)) as error from dual;`
ERROR
---------
1
链接地址: http://www.djcxy.com/p/27218.html
上一篇: 在IE中删除一个窗口属性
下一篇: 数字列显示十六进制字符