DSQL, PSQL

    Syntax

    Result type

    VARCHAR or BLOB

    Description

    Replaces all occurrences of a substring in a string.

    • This function fully supports text BLOBs of any length and character set.

    • If find is the empty string, str is returned unchanged.

    • If any argument is NULL, the result is always NULL, even if nothing would have been replaced.

    Examples

    1. replace ('Billy Wilder', 'il', 'oog') -- returns 'Boogly Woogder'
    2. replace ('Billy Wilder', 'il', '') -- returns 'Bly Wder'
    3. replace ('Billy Wilder', 'il', null) -- returns NULL
    4. replace ('Billy Wilder', 'xyz', null) -- returns NULL (!)

    When used on a BLOB, this function may need to load the entire object into memory. This may affect performance if huge BLOBs are involved.

    See also