title: Postgresql function not working as expected with INSERT INTO
body: <p>I have function to insert data from one table to another</p>
  
  <pre><code>   $BODY$
      BEGIN
              INSERT INTO backups.calls2 (uid,queue_id,connected,callerid2)
              SELECT distinct (c.uid) ,c.queue_id,c.connected,c.callerid2
              FROM public.calls c 
              WHERE c.connected is not null;
          RETURN;
      EXCEPTION WHEN unique_violation THEN NULL;
      END;
  $BODY$
  </code></pre>
  
  <p>And structure of table:</p>
  
  <pre><code>CREATE TABLE backups.nc_calls_id
  (
    uid character(30) NOT NULL,
    queue_id integer,
    callerid2 text,
    connected timestamp without time zone,
    id serial NOT NULL,
    CONSTRAINT calls2_pkey PRIMARY KEY (uid)
   )
  WITH (
    OIDS=FALSE
  );
  </code></pre>
  
  <p>When I have first executed this query, everything went ok, 200000 rows was inserted to new table with unique Id. 
  But now, when I executing it again, no rows are being inserted</p>