title: How to retry transaction after exception in postgreSQL
body: <p>In different parts of my code I have to retry transactions after exceptions. But I cant figure out how to do it.
  Here is my test function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION f() RETURNS VOID AS $$
  DECLARE
      user_cur CURSOR FOR SELECT * FROM "user" WHERE id &lt; 50 limit 10;
      row RECORD;
      counter INTEGER DEFAULT 0;
      dummy INTEGER DEFAULT 0;
  BEGIN
      RAISE INFO 'Start... ';
      OPEN user_cur;
      LOOP
        FETCH user_cur INTO row;
        EXIT WHEN row IS NULL;
  
        BEGIN
          UPDATE "user" SET dummy = 'dummy' WHERE id = row.id;
          counter := counter + 1;
          dummy := 10 / (5 % counter);
          RAISE NOTICE 'dummy % , user_id %', (5 % counter), row.id;
  
        EXCEPTION WHEN division_by_zero THEN
            --What should I do here to retry transaction?
        END;
      END LOOP;
      RAISE INFO 'Finished.';
  
      RETURN;
  END;
  $$ LANGUAGE plpgsql;
  </code></pre>