Version:11.2.0.3
Platform: RHEL 5.8
I am trying to use DECODE function.
In the below example, If the search encounters the string "Enterprise" , then the decode should
return 'Enterprise' . But it doesn't seem to work.
I thought some hidden character was causing the issue, so, I used TRIM. But no luck.
SQL> create table t (banner varchar2(80));
Table created.
SQL> insert into t values ('Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
SQL> select * from t where banner like '%Database%';
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
-- Trying to use decode. If the search encounters the string "Enterprise" , then return 'Enterprise'
-- Although the string "Enterprise" is present , decode doesn't seem to work.
-- I tried using trim , upper . But no luck.
SQL> select 'EDITION', decode(banner,'%Enterprise%','Enterprise','Standard') Edition from t where banner like '%Database%';
'EDITIO EDITION
------- ----------
EDITION Standard
SQL> select 'EDITION', decode(trim(banner), '%Enterprise%','Enterprise','Standard') Edition from t where trim(banner) like '%Database%';
'EDITIO EDITION
------- ----------
EDITION Standard
SQL> select 'EDITION', decode(upper(trim(banner)), '%ENTERPRISE%','Enterprise','Standard') Edition from t where upper(trim(banner)) like '%DATABASE%';
'EDITIO EDITION
------- ----------
EDITION Standard
SQL>
Just don't understand why decode can't see the string "Enterprise"
BTW . Where is the preview button ?