[20120117]函式反轉字串reverse.txt

lfree發表於2012-01-17
[20120117]函式反轉字串reverse.txt
SQL> select * from v$version ;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for Linux: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production

SQL> select reverse('abcd 123') from dual;
REVERSE(
--------
321 dcba

 檢視手冊沒有這麼命令,估計是oracle內部使用的,存在一個問題,如果變數使用數值,出現如下錯誤:

SQL> select reverse(123) from dual;
REVERSE(123)
------------
  -9.900E+77

*** glibc detected *** double free or corruption (out): 0x000000000058d590 ***
rlwrap: warning: sqlplus killed by SIGABRT.
rlwrap has not crashed, but for transparency,
it will now kill itself (without dumping core)with the same signal

Aborted


在11G下測試:

SQL> select * from v$version ;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL> select reverse('abcd 123') from dual ;
REVERSE(
--------
321 dcba

SQL> select reverse(123) from dual ;
select reverse(123) from dual
               *
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected CHAR got NUMBER

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-715034/,如需轉載,請註明出處,否則將追究法律責任。

相關文章