Declaration
INSERT (str1,pos,len,str2)
Description
Returns the string str1, replacing the substring starting at position pos and having length len with str2. If pos exceeds the length of the string, the original string is returned. If len is longer than either of the other strings, the replacement starts from position pos. If any parameter is NULL, the return value is NULL. This function supports multibyte characters.
str1andstr2must be strings, andposandlenmust be integers. If any parameter isNULL, the result is alwaysNULL.The Chinese characters in
str1andstr2are treated as a byte stream.If the value of
posis negative or greater than the length ofstr1,str1is returned.If
lenis less than 0 or greater than the length ofstr1, the result is a concatenation 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