DISQUS

Eddie Awad’s Blog: What you Ought to Know About CASE in Oracle PL/SQL

  • Karl · 2 years ago

    oh!
    this was new to me the differnet behavior of a searched case expression and a statement.
    Great
    Karl

  • Pete Finnigan · 2 years ago

    Nice post Eddie, it would be interesting; if i had any spare time..:-) to see if Duffs device would work with PL/SQL case contructs as they do with C.


    cheers


    Pete

  • Sidhu · 2 years ago

    Good one Eddie


    Learned a new thing :)


    Sidhu

  • Eddie Awad · 2 years ago

    Glad you learned something new guys. I also learned something new today thanks to Pete, the Duff's device. I had to check it out. Very interesting.


    After my limited reading about it, and If I understand it correctly, I do not believe that Duff's device can be simulated in PL/SQL using CASE because there is no "break" in PL/SQL as there is in C. Moreover, unlike C, CASE breaks automatically at the end of a positive WHEN condition block (continues after the END CASE).


    Now, there is this new feature in 11g, CONTINUE, but I do not see that it will make any difference in this case.

  • Reader · 2 years ago

    Seems like an unknown subtlety to even Tom:


    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:67073167580253

  • Not Tom · 1 year ago
    Surprise surprise, Tom wrote a snarky response without reading the post.

    This article and the poster on asktom are talking about CASE in Oracle PL/SQL. Tom is only talking about CASE in Oracle SQL, where you never need the ELSE.

    Bottom line is, you'll only get the CASE_NOT_FOUND exception when omitting the else clause from a case "statement" in PL/SQL.