Re: [GENERAL] referential integrity constraints not checked inside

2004-05-13 Thread James M Moe
Christian Rank wrote: 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); Have you considered using "on delete cascade" in table b? -- jimoe at sohnen-moe dot com -

Re: [GENERAL] referential integrity constraints not checked inside

2004-05-13 Thread Christian Rank
Tom Lane wrote: > Christian Rank <[EMAIL PROTECTED]> writes: > >>... according to the docs, the validity of a constraint should be >>checked after each statement unless this behaviour is altered with a SET >>CONSTRAINTS statement. > > > "Statement" means "interactive command" in that context --

Re: [GENERAL] referential integrity constraints not checked inside

2004-05-13 Thread Tom Lane
Christian Rank <[EMAIL PROTECTED]> writes: > ... according to the docs, the validity of a constraint should be > checked after each statement unless this behaviour is altered with a SET > CONSTRAINTS statement. "Statement" means "interactive command" in that context --- in other words, the constra

Re: [GENERAL] referential integrity constraints not checked inside PL/pgSQL functions?

2004-05-13 Thread Christopher Browne
Supposing you drop the "delete from b;" from the function, you'll find that the function fails with much the same error message you had before. Evidently that foreign key check gets _deferred_ in the context of the stored procedure. It is indeed checked; just not at the point you expect it to be

Re: [GENERAL] referential integrity constraints not checked inside

2004-05-13 Thread Christian Rank
Patrick Welche wrote: > On Thu, May 13, 2004 at 11:41:24AM +0200, Christian Rank wrote: > >> create function f () returns void as ' >> begin >>delete from a; >>delete from b; >>return; >> end; >> ' language plpgsql; >> >>I would expect that >> >> s

Re: [GENERAL] referential integrity constraints not checked inside PL/pgSQL functions?

2004-05-13 Thread Patrick Welche
On Thu, May 13, 2004 at 11:41:24AM +0200, Christian Rank wrote: > create function f () returns void as ' > begin > delete from a; > delete from b; > return; > end; > ' language plpgsql; > > I would expect that > > select f(); > > yields an er

[GENERAL] referential integrity constraints not checked inside PL/pgSQL functions?

2004-05-13 Thread Christian Rank
Hello, I came across the following problem with integrity constraints and PL/pgSQL (PostgreSQL version used: 7.4.2): I defined the following tables, constraints and data: create table a (n integer); create table b (n integer); alter table a add primary key (n); al