title: merge in oracle updating value but not inserting, neither giving error version 11g
body: <p>Update is working fine but insert is not giving any error neither it is inserting unable to understand the issue.</p>
  
  <p>Its single table in which I want to insert/update values</p>
  
  <pre><code>  MERGE INTO SOFT_FILENAME A
    USING (select TC, TC_DT, LASTNO
             FROM SOFT_FILENAME
            where TC = 'KMB'
              AND to_date(tc_dt,'dd-mon-yyyy') = to_date(sysdate,'dd-mon-yyyy')) B
    ON ( A.TC = 'KMB'  AND to_date(A.tc_dt,'dd-mon-yyyy') = to_date(sysdate,'dd-mon-yyyy') AND A.TC_DT = B.TC_DT AND A.TC = B.TC)
  
    when matched then
  
      UPDATE
         SET A.LASTNO = A.LASTNO + 1
       WHERE A.TC = 'KMB'
         AND to_date(A.tc_dt,'dd-mon-yyyy') = to_date(sysdate,'dd-mon-yyyy')
  
  
    WHEN NOT MATCHED THEN
  
      INSERT (A.TC, A.TC_DT, A.LASTNO) VALUES ('KMB', to_date(sysdate,'dd-mon-yyyy'), 1);
  </code></pre>
  
  <p>Table script </p>
  
  <pre><code>create table A
  (
    TC     CHAR(3),
    TC_DT  DATE,
    LASTNO NUMBER(6)
  )
  
  </code></pre>
  
  <p>Alternate way to achieve this using procedure is following way but I don't want to call procedure.
  Following is what I want to achieve using merge.</p>
  
  <pre><code>begin
    select count(1)
      into cou  
      FROM SOFT_FILENAME
     where TC = V_TC
       AND to_date(tc_dt, 'dd-mon-yyyy') = to_date(sysdate, 'dd-mon-yyyy');
    if (cou = 0) then
      INSERT into SOFT_FILENAME A
        (A.TC, A.TC_DT, A.LASTNO)
      VALUES
        (V_TC, sysdate, 1);
    else
      UPDATE SOFT_FILENAME A
         SET A.LASTNO = A.LASTNO + 1
       WHERE A.TC = V_TC
         AND
         to_date(A.tc_dt, 'dd-mon-yyyy') =
             to_date(sysdate, 'dd-mon-yyyy'); 
    end if;
  end
  
  </code></pre>