Αποτελέσματα Αναζήτησης
You can rewrite it to use the ELSE condition of a CASE: SELECT status, CASE status WHEN 'i' THEN 'Inactive' WHEN 't' THEN 'Terminated' ELSE 'Active' END AS StatusText FROM stage.tst
For example, you can use the CASE expression in statements such as SELECT, UPDATE, or DELETE, and in clauses like SELECT, WHERE, HAVING, and ORDDER BY. Oracle CASE expression has two formats: the simple CASE expression and the searched CASE expression. Both formats support an optional ELSE clause.
2 Ιουν 2023 · Table of Contents. What Does the SQL CASE Statement Do? SQL CASE Statement Syntax. Parameters of the CASE Statement. Simple and Searched CASE Expressions. Examples of the CASE Statement. CASE Statement Frequently Asked Questions. There Is No IIF or IF in Oracle. Procedural Languages Have an IF Statement. Conclusion.
In a simple CASE expression, Oracle Database searches for the first WHEN... THEN pair for which expr is equal to comparison_expr and returns return_expr. If none of the WHEN... THEN pairs meet this condition, and an ELSE clause exists, then Oracle returns else_expr. Otherwise, Oracle returns null.
This Oracle tutorial explains how to use the Oracle / PLSQL CASE statement with syntax and examples. The Oracle / PLSQL CASE statement has the functionality of an IF-THEN-ELSE statement. Starting in Oracle 9i, you can use the CASE statement within a SQL statement.
One of the conditions in CASE statements in PL/SQL must be true. If the database reaches the end of the statement without activating one, it raises CASE_NOT_FOUND.
The following example shows a simple CASE statement. Notice that you can use multiple statements after a WHEN clause, and that the expression in the WHEN clause can be a literal, variable, function call, or any other kind of expression.