Ansicht
Dokumentation

ABENSQL_COALESCE - SQL COALESCE

ABENSQL_COALESCE - SQL COALESCE

ROGBILLS - Synchronize billing plans   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.
SAP E-Book

- Coalesce Function

... COALESCE( sql_exp1, sql_exp2, ..., sql_expn ) ...

Effect

Calls the Coalesce function as an SQL expression or operand of an expression in . The Coalesce function can have a comma-separated list with at least two but no more than 255 arguments sql_exp1, sql_exp2, ..., sql_expn. This function returns the values of the first argument, which does not have the null value. If every argument has the null value, the value of the last argument sql_expn is returned. A blank must be placed after the opening parenthesis and in front of the closing parenthesis.

The arguments can be any SQL expressions of all dictionary types except ACCP, DF16_SCL (obsolete), DF34_SCL (obsolete), LCHR, LRAW, PREC, RAWSTRING, STRING, and GEOM_EWKB. The data types of arguments must either be the same or the data type of one argument must be able to fully represent the value of the other data types. The result has the dictionary type of the argument with the largest value range.

Notes

  • The Coalesce function can be used to assign a target object a self-defined value or the result of an expression when null values are read. The type-dependent initial value is assigned by default.
  • A maximum of 10 Coalesce functions can be nested.
CASE WHEN sql_exp1 IS NOT NULL THEN sql_exp1
     WHEN sql_exp2 IS NOT NULL THEN sql_exp2
     ...
     ELSE sql_expn
END

Example

The first three CASE expressions return the null value, since no WHEN condition is met and no ELSE is specified. The result of the fourth CASE expression is not a null value and is returned by COALESCE.

SQL Expressions, Coalesce Function






CPI1466 during Backup   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

Length: 2933 Date: 20240416 Time: 192826     sap01-206 ( 55 ms )