title: How to count every word occurence in a string in a ORACLE loop?
body: <p>I've got a problem which seems simple at first, but really isn't. I'm storing words in a table in such way that pair of strings "A B C D E" and "D E F" becomes:</p>
  
  <pre><code>id  value
  --  -----
  1   A
  1   B
  1   C
  1   D
  1   E
  2   D
  2   E
  2   F
  </code></pre>
  
  <p>And i pass to my ORACLE procedure string which looks like this: "A B C D G". And now I want to check percentage of similarity between strings in the database and string passed as a parameter.</p>
  
  <p>I presume that I have to use one of split functions and use an array. Later check if every word in passed string occurs in the table and then count ids. But there`s a twist: I need precise percentage value. </p>
  
  <p>So, result from example above should look like this:</p>
  
  <pre><code>id percentage
  -- ----------
  1  80              -- 4 out of 5 letters exists in query string (A B C D)
  2  33              -- 1 out of 3 (D)
  </code></pre>
  
  <p>So, my questions are:</p>
  
  <ul>
  <li>what is most effective way to split query string and then iterate on it (table?)</li>
  <li>how to store partial results and then count them?</li>
  <li>how to count final percentage value?</li>
  </ul>
  
  <p>Every help would be greatly appreciated.</p>