Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can't write this in any random function that you don't know who will call:

do $$

begin transaction;

update page set change_count = change_count + 1 where page_id = 1;

if (select change_count = 100 from page where page_id = 1) then

    rollback;
else

    commit;
end if;

$$



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: