title: How to update on conflict postgres
body: <p>I have sql statement</p>
  <pre><code>create table test
  (
      code   varchar,
      date   date,
      code_2 varchar(2),
      type   varchar(4),
      sum    int default 1
  );
  
  alter table test
      add primary key (code, date, type);
  
  insert into test(code, date, code_2, type)
  select (array ['abc', 'xyz'])[ceil(random() * 2)],
         (array ['2021-05-28', '2021-05-27'])[ceil(random() * 2)]::date,
         (array ['qq', 'ee'])[ceil(random() * 2)],
         (array ['ABCD', 'DCBA'])[ceil(random() * 2)]
  from generate_series(1, 1000)
  on conflict (code, date, type)
      do update set sum = excluded.sum + 1;
  </code></pre>
  <p>I want to add a record and sum it on (a group code, date, type) if it exist, if it's not, add new record</p>
  <p>but above sql do not run and the error</p>
  <p><strong>ERROR: ON CONFLICT DO UPDATE command cannot affect row a second time</strong></p>