title: How to find ASCII of every character in string using DB2 Function?
body: <p>I have written a function in DB2 - that is calculating ASCII of records in a particular column. I want to some help as I want to check the ASCII of every single character in string return yes if the ASCII of that record is greater than 127.</p>
  
  <pre class="lang-sql prettyprint-override"><code>BEGIN
  ATOMIC DECLARE POS,
  INT;
  
  IF INSTR IS NULL THEN RETURN NULL;
  
  END IF;
  
  SET
  (
      POS,
      LEN
  )=(
      1,
      LENGTH(INSTR)
  );
  
  
  WHILE POS &lt;= LEN DO IF ASCII( SUBSTR( INSTR, POS, 1 ))&gt; 128 THEN RETURN 'Y';
  
  END IF;
  
  SET
  POS = POS + 1;
  
  END WHILE;
  
  
  RETURN 'N';
  </code></pre>