Home » SQL & PL/SQL » SQL & PL/SQL » Oracle Pl/SQL Case Statement (PL/SQL 10.0)
Oracle Pl/SQL Case Statement [message #608326] Tue, 18 February 2014 12:37 Go to next message
Uncle_Jake
Messages: 2
Registered: February 2014
Location: Home
Junior Member
What is wrong with this case statement? When begin_time is 1400 (military time as varchar(2) with a CHAR_LENGTH of 4 in the database) then the hour should be 2PM. When begin_time is 0930, then the hour should be 9AM. Why can this not be accomplished? What syntax should be employed here?

select room, begin_time
case begin_time
when begin_time = 1400
then hour = 2PM
when begin_time = 1100
then hour = 11AM
when begin_time = 0930
then 9AM
else
8PM
end,
end_time --another column from the mst_meeting_time table
from ODSMGR.MST_MEETING_TIME

I run the query as above and return ORA-00923: FROM keyword not found where expected. I've searched all over the web for an answer for this. It should be simple enough. THANK YOU!

[Updated on: Tue, 18 February 2014 12:38]

Report message to a moderator

Re: Oracle Pl/SQL Case Statement [message #608328 is a reply to message #608326] Tue, 18 February 2014 13:37 Go to previous message
Michel Cadot
Messages: 58558
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

CASE statement has 2 syntaxes;
CASE begin_time WHEN 1400 THEN expression ... ELSE expression END
CASE WHEN begin_time = 1400 THEN expression ... ELSE expression END
You mixed them.
In addition, "then hour = 11AM" is invalid.

Previous Topic: Query help
Next Topic: Struggling with DBMS_JOB.SUBMIT syntax
Goto Forum:
  


Current Time: Fri Jul 25 04:49:41 CDT 2014

Total time taken to generate the page: 0.05573 seconds