Αποτελέσματα Αναζήτησης
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.
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.
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.
The CASE statement evaluates a single expression and compares it against several potential values, or evaluates multiple Boolean expressions and chooses the first one that is TRUE. Syntax. searched_case_statement ::= [ <<label_name>> ] CASE { WHEN boolean_expression THEN {statement;} ... }... [ ELSE {statement;}... ] END CASE [ label_name ...
Oracle Database 23c extended CASE expressions in PL/SQL to support dangling predicates in simple CASE expression. These work like regular simple CASE expressions - you have a single selector. Each WHEN clause may contain a comparison condition and the right-hand side of the formula.
7 Δεκ 2023 · Ensuring the when clauses are in the correct order is one of many things to be aware of when writing case expressions. In this post we’ll dive into: Simple case expressions. Searched case expressions. How to use case in select. How to use case in where. How to use case in joins. Case in PL/SQL.