title: How to get a character delimited substring in DB2?
body: <p>I have a column &quot;employee_Id&quot; in my Table &quot;Employee&quot;.</p>
  <p>employee_Id is having employee name and date of birth. For example :</p>
  <p><code>Jason-21996</code> and <code>Buttler</code></p>
  <p>Please help me  write a select query which returns <code>Jason</code> and <code>Buttler</code> as output.</p>
  <p>This is the query I am trying :</p>
  <p><code>select substring(employee_Id,1, LOCATE('-',employee_Id) - 1) as Emp_ID from Employee</code></p>
  <p>I am seeing this error:</p>
  <pre><code>SQL Error [42815]: THE DATA TYPE, LENGTH, OR VALUE OF ARGUMENT 3 OF SUBSTRING IS INVALID. SQLCODE=-171, SQLSTATE=42815, DRIVER=4.9.78
  </code></pre>
  <p>Edit 1: As suggested by @Mark, I have edited the query as follows</p>
  <p><code>select substring(employee_Id,1, LOCATE('-',employee_Id || '-') - 1) as Emp_ID from Employee</code></p>
  <p>I am getting the same error. I tried to run the LOCATE and found that it is returning the index as 15 for Buttler as the column length is 15.</p>