title: Starting position for replace function in db2
body: <p>I'm converting some Access VBA functionality to DB2 and found a vital difference.  VBA lets you specify the starting point in the character string you're working on.  DB2 doesn't have that option.  It starts from position 1 and replaces whatever you want to be replaced in the whole string. How can I make DB2 start the replace at a specified place in the string? For example, my string is "Incongruent Plastics Incorporated" and I want to replace the second "Inc" at position 22 with "Inc". I'm doing this in a WHILE loop, going through long strings, replacing parts of them until they are less than a specified maximum (15 or 30 depending on the field).</p>
  
  <p>I looked at the Locate function, but I'm not sure that's right.</p>
  
  <pre class="lang-sql prettyprint-override"><code>Replace(a.PAYEE_STD_NAME, B.FullWord, B.abbreviation, B.mLastWord)
  </code></pre>
  
  <p>Where <code>a.PAYEE_STD_NAME</code> is the string I'm looking at, <code>B.FullWord</code> is what I want to replace, <code>B.abbreviation</code> is what I want to replace it with, and <code>B.mLastWord</code> is the position where I want to start replacing.  Something like Replace("Incongruent Plastics Incorporated","Incorporated","Inc",22)</p>
  
  <p>I expect the characters to be replaced starting in the position I need, towards the back of the string, not in the beginning.</p>
  
  <p>Thanks!</p>