Home » SQL & PL/SQL » SQL & PL/SQL » Case Statement - Best Practice - Close with Else Null? (SQL)
Case Statement - Best Practice - Close with Else Null? [message #612750] Thu, 24 April 2014 09:46 Go to next message
smedvid
Messages: 5
Registered: April 2014
Junior Member
Greetings...
I have assumed a set of SQL Code that is massive in size. I have found that Case Statements are not consistent in design. In some instances, the Case Statements have a "Else Null" (properly closing the conditions). In other times there is no Else condition. I am under the believe that NULL is the Oracle Default if "Else ..." is not used. I cannot locate any Oracle Documentation on this belief!

Or >> Is it best practice to rework; and add "Else Null" to all Case Statements to formerly close conditions?

I look forward to your input. tia...

Re: Case Statement - Best Practice - Close with Else Null? [message #612754 is a reply to message #612750] Thu, 24 April 2014 09:59 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to this forum.

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and please read http://www.orafaq.com/forum/t/174502/102589/


When all else fails Read The Fine Manual.

"In a simple CASE expression, Oracle Database searches for the first WHEN ... THEN pair for which expr is equal to comparison_expr and returns return_expr. If none of the WHEN ... THEN pairs meet this condition, and an ELSE clause exists, then Oracle returns else_expr. Otherwise, Oracle returns null."

http://docs.oracle.com/cd/E16655_01/server.121/e17209/expressions004.htm#SQLRF52072
Re: Case Statement - Best Practice - Close with Else Null? [message #612757 is a reply to message #612754] Thu, 24 April 2014 10:12 Go to previous message
smedvid
Messages: 5
Registered: April 2014
Junior Member
Thanks! And just what I am seeking!
I am re-new to Oracle... having taken a break and using SQL Server... for over a decade plus...
Previous Topic: ORA-28002 error while connecting DB LINK
Next Topic: Get information from LDAP
Goto Forum:
  


Current Time: Fri Apr 26 14:13:39 CDT 2024