Re: Case Statement

From: Andreas Leitgeb <avl_at_gamma.logic.tuwien.ac.at>
Date: 29 Sep 2011 19:46:45 GMT
Message-ID: <slrnj89ip5.6gl.avl_at_gamma.logic.tuwien.ac.at>


ExecMan <artmerar_at_yahoo.com> wrote:
> This is interesting, anyone ever get this?
>
> Here is my calling line: exec customer_report(12345, '', 12345)
>
> PROCEDURE customer_report (p_customer_id NUMBER, p_adid VARCHAR2,
> p_product_id NUMBER) IS
>
> This fails the WHEN and executes the ELSE
> v_adid := CASE p_adid
> WHEN NULL THEN ' '
> ELSE ' AND UPPER(ss.adid) = UPPER(''' || p_adid ||
> ''')'
> END;
>
> This works fine and executes the proper IF side.
>
> IF p_adid IS NULL THEN
> v_adid := ' ';
> ELSE
> v_adid := ' AND UPPER(ss.adid) = UPPER(''' || p_adid || ''')';
> END IF;
>
> What is the difference?

I'd tend to believe that CASE makes comparisons, and thus your CASE statement was equivalent to "IF p_adid = NULL THEN ..." (with "=" not "IS") Received on Thu Sep 29 2011 - 21:46:45 CEST

Original text of this message