dbTalk Databases Forums  

"CASE when" strange

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss "CASE when" strange in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
web_poster03@yahoo.com
 
Posts: n/a

Default "CASE when" strange - 05-20-2005 , 09:52 AM






The following 2 queries are different only w/ or w/o "as 'test'".

Oracle server and client info:
SQL*Plus: Release 9.2.0.1.0 - Production on Fri May 20 10:44:37 2005

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Oracle Data
Mining options
JServer Release 9.2.0.4.0 - Production

SQL> select case when sysdate is null then 'nulldate'
2 else to_char(sysdate) end as 'test'
3 from dual;
else sysdate end as 'test'
*
ERROR at line 2:
ORA-00923: FROM keyword not found where expected



1 select case when sysdate is null then 'nulldate'
2 else to_char(sysdate) end
3* from dual
SQL> /

CASEWHENS
---------
20-MAY-05


Reply With Quote
  #2  
Old   
Barbara Boehmer
 
Posts: n/a

Default Re: "CASE when" strange - 05-20-2005 , 10:53 AM






You need to either use double quotes or no quotes at all around test,
not single quotes. Please see the examples below.

scott@ORA92> select case when sysdate is null then 'nulldate'
2 else to_char (sysdate) end as test
3 from dual
4 /

TEST
---------
20-MAY-05

scott@ORA92> select case when sysdate is null then 'nulldate'
2 else to_char (sysdate) end as "test"
3 from dual
4 /

test
---------
20-MAY-05

scott@ORA92>


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.