Logo SQLinForm

 

Re: CASE Statements

CASE Statements
May 31, 2012 08:11PM
I will like to be able to format my SQL CASE Statements like so

CFE_Contin_Readonly  = CASE WHEN(r.Contingence = 1 OR  s.Cat = 1) THEN 0 ELSE 1 END,

Or so

CouleurBase          = CASE WHEN r.OnlyPCC     = 1 THEN 'Orange'
                            WHEN s.Cat         = 1 THEN 'Rose'  
                            WHEN r.Contingence = 0 THEN 'Jaune' 
                            WHEN r.Contingence = 1 THEN 'Jaune'
                            ELSE ''       
                       END,

Or so

CouleurContin        = CASE WHEN r.OnlyPCC     = 1 
                                 THEN 'Bleu' 
                            WHEN s.Cat         = 1 
                                 THEN 'Rose' 
                            WHEN r.Contingence = 1 
                                 THEN 'Jaune' 
                            ELSE 'Orange' 
                       END,

I am open to suggestion.

It is just that when I uncheck the checkbox "Put Linebreaks for CASE Statement". The checkbox for WHEN, THEN, ELSE ... are also deactivate.

Thanks
Re: CASE Statements
June 15, 2012 03:35PM
Hi Tazquebec,
thanks for your suggestion. I understand that you what whant ot keep the WHEN on the same line as the CASE. Is this correct?
Regards
Guido
Author:

Your Email (Optional):


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 7 plus 21?
Message: