Syntax
INSERT (str1,pos,len,str2)
Purpose
Returns the string str1 with the substring starting at position pos and of length len replaced by str2. If pos exceeds the length of the string, the original string is returned. If len is greater than the length of the string, the replacement starts at position pos. If any argument is NULL, the result is NULL. This function supports multibyte characters.
str1andstr2must be strings, andposandlenmust be integers. If any argument isNULL, the result isNULL.Characters in
str1andstr2are treated as byte streams.If
posis negative or greater than the length ofstr1,str1is returned.If
lenis less than 0 or greater than the length ofstr1, the result is the combination of the substring ofstr1from the beginning to positionposandstr2.
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
