Oracle in If/else

Source: Internet
Author: User
Tags switch case

1. Standard SQL specification

One, single IF1, if A=  ... Then.........end if;2, if a= ... then......else....end if; two, more IfIf a=.  Then......elsif a=.  Then....end if;     The middle here is "elsif", not else IF. Special attention is needed here.

2. Decode function

syntax for decode :

DECODE (Value,if1,then1,if2,then2,if3,then3,..., else)

Indicates that if value equals IF1, the result of the Decode function returns THEN1,..., if it is not equal to any one if value, else is returned.


3. Case

Case when a= ' 1 ' and ' xxxx ' when     a= ' 2 ' then ' ssss ' else
' Zzzzz ' End as

Note the point:

1. Start with case and end With end
2. When the branch is followed by the condition, then the result is displayed
3, else in addition to the default, similar to the high-level language program switch case default, you can not add
4, END followed by alias

Category: Db-oracle

Oracle in If/else

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.