Multiple actions in case statement possible?

  • I'm wondering if it's possible to nest multiple actions in one case statement. I basically need to do something like:

    Select

    Case

    When LTrim(RTrim(CF_Program_Broker.STD)) = 'F' Then

    LTrim(RTrim(CF_Program_Broker.STD)),

    Cast(CF_Program_Broker.Promo_Amt as float),

    Cast(CF_Program_Broker.Invoice_Price as money),

    Cast(CF_Program_Broker.Promo_Amt as money),

    Abs(.0000),

    END

    I'm not sure if this is even possible. but I need a way to change multiple fields based on what this CF_Program_Broker.STD field has for a value.

    Thanks,

    Ben

  • You are trying to return mutliple columns inside your CASE, it is not supported, as per your requirements it is better to use IF ELSE Blocks. You can nest multiple CASE statements but you cannot perform what you have posted.

     

    Prasad Bhogadi
    www.inforaise.com

  • You'll need one CASE per column returned... sounds long but runs very fast.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply