please ignore, i overlooked the obvious. truncate table t; TRUNCATE TABLE postgres=# do $$ declare valuelist int[] := ARRAY[1,2,3,4,5,1]; -- purposely inserting duplicate that would rollback everything declare i int; begin for i in select k from unnest(valuelist) p(k) loop insert into t values(i); raise notice 'trying to insert %', i; commit; end loop; end; $$; NOTICE: trying to insert 1 NOTICE: trying to insert 2 NOTICE: trying to insert 3 NOTICE: trying to insert 4 NOTICE: trying to insert 5 ERROR: duplicate key value violates unique constraint "t_pkey" DETAIL: Key (id)=(1) already exists. CONTEXT: SQL statement "insert into t values(i)" PL/pgSQL function inline_code_block line 6 at SQL statement postgres=# table t; id ---- 1 2 3 4 5 (5 rows)
sorry.