Skip site navigation (1) Skip section navigation (2)

Deferred Constraints Issues

From: kevin kempter <kevin(at)kevinkempterllc(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Deferred Constraints Issues
Date: 2008-03-25 20:10:07
Message-ID: B9831791-E41D-4382-A6B4-35A28BA5B02E@kevinkempterllc.com (view raw or flat)
Thread:
Lists: pgsql-admin
Hi List;

I've placed this sql in a script:

psql my_db <<!
begin;
SET CONSTRAINTS ALL DEFERRED ;
delete from account where 1 = 1;
delete from cust where 1 = 1;
delete from cust_type where 1 = 1;
delete from cust_orders where 1 = 1;
commit;
!

The tables have relationships, however I expect the 'SET CONSTRAINTS  
ALL DEFERRED' to defer constraint checks.  When I run the script I get  
this:


BEGIN
SET CONSTRAINTS
ERROR:  update or delete on table "account" violates foreign key  
constraint "account_rel" on table "cust_type"
DETAIL:  Key (account_id)=(1) is still referenced from table  
"cust_type".
ERROR:  current transaction is aborted, commands ignored until end of  
transaction block
ERROR:  current transaction is aborted, commands ignored until end of  
transaction block
ERROR:  current transaction is aborted, commands ignored until end of  
transaction block
ROLLBACK


Am I doing something wrong ? Or, is the 'SET CONSTRAINTS ALL DEFERRED'  
not working properly ?


Thanks in advance...




Responses

pgsql-admin by date

Next:From: Stephan SzaboDate: 2008-03-25 20:27:00
Subject: Re: Deferred Constraints Issues
Previous:From: Marc FrommDate: 2008-03-25 19:31:57
Subject: restore message . . . cascade

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group