PL/SQL daily question: difference between a CASE statement and a CASE expression

Source: Internet
Author: User

PL/SQL daily question: the difference between a CASE statement and a CASE expression: there are many different types of guinea pigs in the world, some of which have identifiable characteristics. For example, the "Abyssinians" skin has a pleated garlands www.2cto.com "Texels" with long curly hair. In contrast, the White Crested Guinea Pig on the header contains a White pattern (as expected). Each of the following options provides an implementation method for the plch_proc process, it displays the guinea pigs with the given features. This process is incomplete. Which of the following lines will be displayed after the following code blocks are executed? [SQL] www.2cto.com Species = Texel Species = BEGIN plch_proc ('curly '); plch_proc ('white'); END;/[SQL] () create or replace procedure plch_proc (feature_in VARCHAR2) IS invalid VARCHAR2 (100); begin case feature_in WHEN 'curly 'then usage: = 'text'; WHEN 'rosettes 'THEN usage: = 'abyssinian '; end case; DBMS_OUTPUT.put_line ('species =' | l_guinea_pig_species); END;/(B) CREATE OR REPLACE PROCEDURE plch_proc (feature_in VARCHAR2) IS l_guinea_pig_species VARCHAR2 (100); BEGIN l_guinea_pig_species: = CASE feature_in WHEN 'curly 'then' Texel 'when' rosettes 'then' Abyssinian 'end; sums ('species = '| l_guinea_pig_species); END;/(C) create or replace procedure plch_proc (feature_in IN VARCHAR2) IS l_guinea_pig_species VARCHAR2 (100 ); begin case feature_in WHEN 'curly 'THEN l_guinea_pig_species: = 'text'; WHEN 'rosettes' THEN l_guinea_pig_species: = 'abyssinian '; else null; end case; sums ('species = '| l_guinea_pig_species); END;/(D) create or replace procedure plch_proc (feature_in IN VARCHAR2) IS l_guinea_pig_species VARCHAR2 (100 ); begin if feature_in = 'curly 'then l_guinea_pig_species: = 'text'; ELSIF feature_in = 'rosettes 'then l_guinea_pig_species: = 'abyssinian '; end if; DBMS_OUTPUT.put_line ('species = '| l_guinea_pig_species); END;/answer: -- BCD pay attention to the CASE statement (statement) and CASE expression (expression) the difference in the absence of else a is a case statement, encounter A branch without processing and the lack of ELSE clause will report an error: "ORA-06592: CASE not found while executing CASE statement "B uses a CASE expression and returns NULL C: With ELSE NULL protection D: IF statements do not report errors because they do not meet the conditions.

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.