Oracle PL/SQL CASE Statement - Shikshaglobe

The CASE statement in PL/SQL is a type of control structure that allows you to execute a sequence of statements based on a condition. It is similar to the IF-THEN-ELSE statement in other programming languages. The CASE statement has two forms: simple and searched. In the simple form, the CASE statement compares an expression to a set of values and returns a result based on the first matching value. In the searched form, the CASE statement evaluates multiple conditions and returns a result based on the first condition that is TRUE.The CASE statement has two forms: simple and searched. The simple CASE statement compares an expression to a set of literal values and returns the result of the first comparison that is TRUE. If no match is found, then the ELSE clause expressions are returned, or NULL if there is no ELSE clause.The searched CASE statement evaluates multiple Boolean expressions and returns the first result that is TRUE. If no match is found, then the ELSE clause expressions are returned, or NULL if there is no ELSE clause.A CASE statement is used to make decisions based on a set of conditions. The CASE statement starts with the keyword CASE, followed by an expression. The expression is compared to the values in each WHEN clause in order until a match is found. If no match is found, the ELSE clause is executed. If there is no ELSE clause and no match is found, nothing is executedThe following example shows how to use the CASE statement:DECLAREgrade char(1);BEGINgrade := 'B';CASE gradeWHEN 'A' THEN dbms_output.put_line('Excellent')WHEN 'B' THEN dbms_output.put_line('Very Good');WHEN 'C' THEN dbms_output.put_line('Good');WHEN 'D' THEN dbms_output.put_line('Fair');WHEN 'F' THEN dbThe CASE statement in Oracle PL/SQL has two forms: simple CASE and searched CASE. Simple CASE evaluates an expression for a match to a set of values, and returns the result corresponding to the first matching value. Searched CASE evaluates multiple Boolean expressions and returns the first result that is TRUE. NULL is not a valid value for either type of CASE expression.

Tags:

oracle pl/sql case statementoracle pl sql case statement in where clauseoracle pl sql case statement multiple valuesoracle pl sql case statement in selectoracle pl/sql case statement examplesoracle pl sql switch case statementoracle pl-sql update with case statementoracle pl sql nested case statementoracle 12c pl sql case statementoracle apex pl sql case statementoracle pl/sql case statement exampleoracle pl sql case when andcase statement in oracle pl/sql blockoracle pl sql case when multiple conditionsoracle pl/sql case statement defaultoracle pl/sql case statement default valueoracle pl/sql case statement dateoracle pl/sql case statement duplicate rowsoracle pl/sql case statement db2oracle pl sql case statement date greater thanoracle pl sql case statement date is nulloracle pl sql case statement deleteoracle pl sql case statement distinctoracle pl sql case statement duplicateoracle pl/sql case when exampleoracle pl/sql case when existsoracle pl/sql case when elseoracle pl/sql case when end functionoracle pl/sql case when then elseoracle 11g pl sql case statement exampleoracle pl sql compare datesoracle pl/sql case statement functionoracle pl/sql case statement for multiple conditionsoracle pl/sql case statement for multiple valuesoracle pl/sql case statement for where clauseoracle pl/sql case statement formattingoracle pl/sql case statement for fundraisingoracle pl/sql case statement fallthroughoracle pl sql case statement field is nulloracle pl sql case statement for looporacle pl sql case statement falseoracle pl/sql case statement group byoracle pl/sql case statement greater thanoracle pl/sql case statement greater than or equal tooracle pl sql case statement gotooracle pl sql case statements generate insertoracle pl/sql case statement helporacle pl/sql case statement howoracle pl/sql case statement hintoracle pl/sql case statement hierarchyoracle pl sql case statement handlingoracle pl sql case statement havingoracle pl sql case statement how to usehow to use case statement in oracle pl sqlcase statement in pl/sql oracleoracle pl sql case in select statementoracle pl sql case in update statementnested case statement in oracle pl sqlpl/sql case statement exampleoracle pl/sql case statement joinoracle pl/sql case statement javaoracle pl/sql case statement join two tablesoracle pl/sql case statement join sqloracle pl/sql case statement keywordoracle pl/sql case statement keyoracle pl/sql case statement key value pair