Syntax
INSERT(str1,pos,len,str2)
Purpose
INSERT() returns the str1 string, which starts from pos. Substrings with a length of len are replaced with str2. If pos exceeds the string length, the original string is returned. If len is greater than the length of other strings, the substring starting from the position pos is replaced. If any argument is NULL, the return value is NULL. This function supports multi-byte characters.
str1andstr2must be strings, andposandlenmust be integers. If any argument isNULL, the return value isNULL.The characters in
str1andstr2are considered byte streams.If
posis a negative value or exceeds the length ofstr1,str1is returned.When
lenis less than 0 or exceeds the length ofstr1, a string that combinesstr1from the beginning toposandstr2is returned.
Examples
obclient> SELECT INSERT('Quadratic',-2,100,'What'), INSERT('Quadratic',7,3,'What'),
INSERT('Quadratic',-1,3,'What'), INSERT('Quadratic',10,3,'What'), INSERT('Quadratic',5,-1,''),
INSERT('Quadratic',7,-1,'What')\G
*************************** 1. row ***************************
INSERT('Quadratic',-2,100,'What'): Quadratic
INSERT('Quadratic',7,3,'What'): QuadraWhat
INSERT('Quadratic',-1,3,'What'): Quadratic
INSERT('Quadratic',10,3,'What'): Quadratic
INSERT('Quadratic',5,-1,''): Quad
INSERT('Quadratic',7,-1,'What'): QuadraWhat
1 row in set