@COLTEST
Use the @COLTEST function to enable conditional calculations by testing for one or more column conditions. If a condition is satisfied, @COLTEST returns TRUE. To perform the conditional calculation, use the @IF function.
Syntax
@COLTEST (source_column, test_condition [, test_condition] [, ...])
-
source_column -
The name of a source column.
-
test_condition -
Valid values:
-
PRESENT -
Indicates a column is present in the source record and not
NULL. Column values can be missing if the database does not log values for columns that do not change, but that is not the same asNULL. -
NULL -
Indicates a column is present in the source record and
NULL. -
MISSING -
Indicates a column is not present in the source record.
-
INVALID -
Indicates a column is present in the source record but contains invalid data.
-
Examples
- Example 1
-
The following example uses
@IFto map a value to theHIGH_SALARYcolumn only if theBASE_SALARYcolumn in the source record was both present (and notNULL) and greater than 250000. Otherwise,NULLis returned.HIGH_SALARY = @IF (@COLTEST (BASE_SALARY, PRESENT) AND BASE_SALARY > 250000, BASE_SALARY, @COLSTAT (NULL))
- Example 2
-
In the following example, 0 is returned when the
AMTcolumn is missing or invalid; otherwise a value forAMTis returned.AMOUNT = @IF (@COLTEST (AMT, MISSING, INVALID), 0, AMT)
- Example 3
-
The following example maps
+nanand+snanto 0 in the trail forcolcolumn for all the targets even if the special value is supported .TABLE src_table COLMAP(col = @if(@COLTEST(col, NAN, SNAN), 0, col))
- Example 4
-
The following example maps
Infinity/-Infinityto 0 in the trail forcolcolumn to override the default mapping to a specific target.MAP src_table, TARGET tgt_table, COLMAP(col = @if(@COLTEST(col, INF, -INF), 0, col))