Other Functions

DECODE

Syntax

DECODE(base_expr,
       compare_1, value_1,
       compare_2, value_2,
       …
       compare_i, value_i,
       default)

Description

The DECODE function is similar to a sequence of built-in operators IF-THEN-ELSE. The basic expression (base_expr) is successively compared with the expressions compare_1, compare_2,…,compare_i. If the basic expression corresponds to the i-th point of comparison (compare_i ), the i-th value is returned (value_i). If the basic expression does not match any of the points the default value is returned. Comparison expressions are considered by turn. If the match is fount, other expressions are not compared. If the default value has not been specified, NULL is returned.

Example

DECODE(PERSON,'F','1','M','-1',0) <> 0

The PERSON field should contain only the symbols F and M.

NVL

Syntax

NVL(expr1, expr2)

Description

The NVL function returns the expr2 value if the expr1 contains the NULL value, otherwise it returns expr1.

Example

NVL(ID_PARENT, ID_CHILD) IS NOT NULL

The ID_PARENT and ID_CHILD cannot both contain the NULL value at the same time.

CALL_DATE

Syntax

CALL_DATE(proc[, param])

Description

The CALL_DATE function returns a date which is the result of the procedure PROC registered in the base. Param is one or several expressions (an optional parameter) that are regarded as a parameter when the procedure PROC is called.

Example

DT = CALL_DATE(PROC_1)

The date in the DT field should match the date returned by the procedure PROC_1.

CALL_NUMBER

Syntax

CALL_NUMBER(proc[, param])

Description

The CALL_NUMBER function returns a number which is the result of the procedure PROC registered in the base. Param is one or several expressions (an optional parameter) that are regarded as a parameter when the procedure PROC is called.

Example

NUM = CALL_NUMBER(PROC_1)

The value in the NUM field should match the value returned by the procedure PROC_1.

CALL_VARCHAR

Syntax

CALL_VARCHAR(proc[, param])

Description

The CALL_VARCHAR function returns a string which is the result of the procedure PROC registered in the base. Param is one or several expressions (an optional parameter) that are regarded as a parameter when the procedure PROC is called.

Example

STR = CALL_VARCHAR(PROC_1)

The string in the STR field should match the string returned by the procedure PROC_1.

See also:

Built-in SQL Functions | Table Constraints