INSERT

Purpose

This function replaces the substring of string, with length length beginning at position, with string new_string.

Syntax

insert::=

Usage Notes

  • The first character of string has position 1. If the variable position is 0 or outside the string, then the string is not changed. If it is negative, then the function counts backwards from the end.
  • If length=0, then new_string is just inserted and nothing is replaced.
  • If position+length>length(string) or if length<0, then the string is replaced beginning from position.
  • If one of the parameters is NULL, then NULL is returned.

Example

SELECT INSERT('abc',2,2,'xxx'),
       INSERT('abcdef',3,2,'CD');
Result
INSERT('abc',2,2,'xxx') INSERT('abcdef',3,2,'CD')
axxx abCDef