SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
CASE formating

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
CASE formating
Author Message
Olegon



Joined: 07 Sep 2009
Posts: 39
Country: Kazakhstan

Post CASE formating Reply with quote
Hello

How to set code formatting to get:

Code:
select
  some_value = 1234.56,
  some_status =
    case
      when status_sign = 1
      then 'Yes'
      else 'No'
    end


Instead of this:

Code:
select
  some_value = 1234.56,
  some_status = case
                  when status_sign = 1
                  then 'Yes'
                  else 'No'
                end


Is it possible?

Thanks!
Thu Mar 29, 2012 12:27 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
I think you can modify code formatting rule for CASE and in front of it specify ...

But, I don't think you always want CASE to start on the same line, and the rule won't be able to figure out when to do that and when not, for example,

...
ORDER BY colA,
CASE WHEN 1 > 0 ...
.... long long expression here ...

In the above case, you likely don't want CASE to be after colA, right?


Lastly, the syntax alias = expression is outdated, non ANSI compliant and as Microsoft stated might be discontinued in some future. Its better not to use it. If you swith to standard syntax expression AS alias you won't need to deal with that special context sensitive CASE formatting rule


Last edited by SysOp on Thu Apr 05, 2012 1:04 pm; edited 1 time in total
Thu Mar 29, 2012 7:47 am View user's profile Send private message
Olegon



Joined: 07 Sep 2009
Posts: 39
Country: Kazakhstan

Post Reply with quote
SysOp wrote:

Lastly, the syntax alias = expression is outdated, non ANSI compliant and as Microsoft stated might be discontinued in some future. Its better not to use it. If you swith to standard syntax expression AS alias you won't need to deal with that special context sensitive CASE formatting rule


Yes, maybe... But how about this:
Code:

update
set
  field_name =


:)

It does not matter where.
I used to write a CASE on the next line. So wanted to know how to set the formatting options.
Thu Apr 05, 2012 4:46 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
Hi,

Have you tried adding 3 dots ... in front of CASE as it was suggested in the previous post? Does it work for you?


Please consider that there is only 1 formatting rule for CASE. It's not context sensitive, in all cases it should work the same.
Thu Apr 05, 2012 1:04 pm View user's profile Send private message
Olegon



Joined: 07 Sep 2009
Posts: 39
Country: Kazakhstan

Post Reply with quote
SysOp wrote:

Have you tried adding 3 dots ... in front of CASE as it was suggested in the previous post? Does it work for you?


Isn't work.
I get this:

Code:
select
  filed =
          case
            when 1 = 1
            then 1
            else 0
          end


SysOp wrote:

Please consider that there is only 1 formatting rule for CASE. It's not context sensitive, in all cases it should work the same.


Yes, I understand.
Thu Apr 05, 2012 10:28 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.