Have you considered using "on delete cascade" in table b?
create table a (n integer); create table b (n integer); alter table a add primary key (n); alter table b add foreign key (n) references a(n);
-- jimoe at sohnen-moe dot com
---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org