I want to roll back deletion if there is a reference (FK) in another table.
Can I explicitly call a rollback inside a function?


CREATE OR REPLACE FUNCTION pre_del_prod_proc()
returns trigger as $$
begin
        if exists (select 1 from host_config where config_id = OLD.id) then
            rollback;
        end if;
end;
$$ language plpqsql;

CREATE TRIGGER pre_del_prod_proc
before delete on prod_config
for each row execute procedure pre_del_prod_proc();

Thanks,
Quang.

Reply via email to