title: Procedure to find multiples values in a table and insert if doesnt exist using pl/sql
body: <p>I have this <strong>table</strong> with this relationship: <strong>UNIT</strong> --> <strong>CHARGE</strong> ---> <strong>ROLE</strong></p>
  
  <pre><code>UNIT_CODE    |    CHARGE_CODE    |    ROLE_CODE
  0101010001   |     9023409       |    AZAAAA
  0102010002   |     8023409       |    AXAAAB
  0103010003   |     7023409       |    ACAAAC
  0104010004   |     6023409       |    AVAAAV
  0101010001   |     5023409       |    NEWROL
  0102010002   |     4023409       |    AZAAAA
  </code></pre>
  
  <p>This table has almost 2.000 rows/line.</p>
  
  <p>So, here is the situations:</p>
  
  <p>I have to insert a specific ROLE_COD (<code>NEWROL</code>) for a specific 90 <strong>unit_code</strong>. But this role apply for a specific charge of the units.</p>
  
  <p>Example: i have to insert the <strong>role_code</strong> = <code>NEWROLE</code> for this <strong>units</strong> <code>0101010001</code> and this <strong>charge</strong> <code>5023409</code></p>
  
  <ul>
  <li><p>So, i have to check:</p>
  
  <ol>
  <li>If units <code>0101010001</code> already exist? - YES</li>
  <li>If the <strong>unit / charge</strong> <code>0101010001 / 5023409</code> relationship already exist? - YES</li>
  <li>If the <strong>unit / charge / rol</strong> <code>0101010001 / 5023409 / NEWROL</code> already exist?  - YES</li>
  </ol></li>
  </ul>
  
  <p>If the answer is YES for the 3 questions i have to check other <strong>unit / charge</strong> combinations:</p>
  
  <p><code>0102010002   / 4023409</code></p>
  
  <ol>
  <li>If <strong>units</strong> <code>0102010002</code> already exist? - YES</li>
  <li>If the <strong>unit / charge</strong> <code>0102010002 / 4023409</code> relationship already exist? - YES</li>
  <li>If the <strong>unit / charge / rol</strong> <code>0102010002 / 4023409 / NEWROL</code> already exist?  - NO</li>
  </ol>
  
  <p>So i have to insert into the table the role: NEWROL for this units/charge and check the other units and charge.</p>
  
  <p><strong>NOTE:</strong> The units are unique, but some units have the same/multiples roles or charge.</p>
  
  <p>I have to check 90 units, i need a procedure to take the <code>unit_code</code> and <code>charge</code> to make the validations and insert the <code>role_code</code> if necesary.</p>