OVERLAYB
Returns an octet value representing a string having had a substring replaced by another string.
Behavior Type
Syntax
OVERLAYB ( expression1, expression2, position [ , extent ] )
Parameters
expression1 |
(CHAR or VARCHAR) is the string to process |
expression2 |
(CHAR or VARCHAR) is the substring to overlay |
position |
(INTEGER) is the octet position (counting from one) at which to begin the overlay |
extent |
(INTEGER) specifies the number of octets to replace with the overlay |
Notes
The OVERLAYB function treats the multibyte character string as a string of octets (bytes) and use octet numbers as incoming and outgoing position specifiers and lengths. The strings themselves are type VARCHAR, but they treated as if each byte was a separate character.
Examples
=> SELECT OVERLAYB('123456789', 'ééé', 2); OVERLAYB ---------- 1ééé89 (1 row)
=> SELECT OVERLAYB('123456789', 'ßßß', 2); OVERLAYB ---------- 1ßßß89 (1 row)
=> SELECT OVERLAYB('123456789', 'xxx', 2); OVERLAYB ----------- 1xxx56789 (1 row)
=> SELECT OVERLAYB('123456789', 'xxx', 2, 4); OVERLAYB ---------- 1xxx6789 (1 row)
=> SELECT OVERLAYB('123456789', 'xxx', 2, 5); OVERLAYB ---------- 1xxx789 (1 row)
=> SELECT OVERLAYB('123456789', 'xxx', 2, 6); OVERLAYB ---------- 1xxx89 (1 row)