title: Oracle Merge. How can I use it?
body: <p>I have this function:</p>
  
  <pre><code>      Procedure UpdateDefaultWeight  ( vYear Number, costWeight Number, qualityWeight Number, serviceWeight Number ) 
        AS
  
          type weight_table is table of Number(5,2) index by varchar2(50);
          weightArray weight_table;
          currentPosition varchar2(50);
        Begin
  
          weightArray('Cost Weighting')    := costWeight;
          weightArray('Quality Weighting') := qualityWeight;
          weightArray('Service Weighting') := serviceWeight;
  
          currentPosition := weightArray.first;
  
          Loop
            Exit When currentPosition is null;
            Insert Into GVS.GVSSD16_DFLT_WEIGHT
              ( cal_year, metric_name, metric_val )
            Values
              ( vYear, currentPosition, weightArray(currentPosition) ); 
  
            currentPosition := weightArray.next(currentPosition);
          End Loop;
        END;
  </code></pre>
  
  <p>Right now as I wrote it, it just does an INSERT.  However, I need it to UPSERT.  I've looked around at documentation on MERGE, but mainly it's just left me confused on how to apply the syntax to my specific case.</p>
  
  <p>I've looked <a href="https://stackoverflow.com/questions/237327/oracle-how-to-upsert-update-or-insert-into-a-table">here</a> and <a href="http://www.idevelopment.info/data/Oracle/DBA_tips/SQL/SQL_14.shtml" rel="nofollow noreferrer">here</a> and I get the jist of it, but syntax fails me.</p>
  
  <p>Anyone care to help an Oracle newbie out?</p>