Home » SQL & PL/SQL » SQL & PL/SQL » gettint error while using case in sql statement
gettint error while using case in sql statement [message #300738] Mon, 18 February 2008 00:13 Go to next message
jitender.sadh
Messages: 82
Registered: May 2007
Member
hi,

i am getting error when i am using case clause in sql statement

SQL> select sal, case when sal < 2000 then 'category 1' 
  2                   when sal < 3000 then 'category 2' 
  3                   when sal < 4000 then 'category 3' 
  4                   else 'category 4' 
  5              end 
  6  from emp;
select sal, case when sal < 2000 then 'category 1'
                      *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected


regards
jitender
Re: gettint error while using case in sql statement [message #300751 is a reply to message #300738] Mon, 18 February 2008 00:47 Go to previous messageGo to next message
kkinapps
Messages: 29
Registered: November 2006
Location: Hyderabad
Junior Member

Hi Jitender,

I tried with your case statement and it was working fine in sql*plus...

Quote:

SQL> select sal, case when sal < 2000 then 'category 1'
2 when sal < 3000 then 'category 2'
3 when sal < 4000 then 'category 3'
4 else 'category 4'
5 end
6 from emp;

SAL CASEWHENSA
---------- ----------
500 category 1
1600 category 1
1250 category 1
2975 category 2
1250 category 1
2850 category 2
2450 category 2
3000 category 3
5000 category 4
1500 category 1
1100 category 1

SAL CASEWHENSA
---------- ----------
950 category 1
3000 category 3
1300 category 1
category 4
category 4
category 4
category 4
category 4
category 4

20 rows selected.

SQL>



Regards
KK
Re: gettint error while using case in sql statement [message #300756 is a reply to message #300738] Mon, 18 February 2008 00:51 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
jitender.sadh wrote on Mon, 18 February 2008 07:13
hi,

i am getting error when i am using case clause in sql statement


What database version are you running this on?
Re: gettint error while using case in sql statement [message #300802 is a reply to message #300756] Mon, 18 February 2008 02:50 Go to previous messageGo to next message
jitender.sadh
Messages: 82
Registered: May 2007
Member
hi

the oracle version i am using is
----------------------------------------------------------------
Oracle8i Release 8.1.5.0.0 - Production
PL/SQL Release 8.1.5.0.0 - Production
CORE Version 8.1.5.0.0 - Production
TNS for 32-bit Windows: Version 8.1.5.0.0 - Production
NLSRTL Version 3.4.0.0.0 - Production


regards
jitender
Re: gettint error while using case in sql statement [message #300813 is a reply to message #300802] Mon, 18 February 2008 03:13 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
CASE expressions were introduced in 8.1.6.

Regards
Michel
Re: gettint error while using case in sql statement [message #300816 is a reply to message #300802] Mon, 18 February 2008 03:15 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
[Removed text]

Never mind. Michel posted the correct introduction-version

[Updated on: Mon, 18 February 2008 03:16]

Report message to a moderator

Previous Topic: Pseudo-column
Next Topic: ORA-00920: invalid relational operator
Goto Forum:
  


Current Time: Sat Dec 10 14:35:13 CST 2016

Total time taken to generate the page: 0.09279 seconds