RE: cascading delete does not work
Posted in 2000
Is your database logged?
You cant do cascade delete with an unlogged database
From my Syntax Guide
pg 2-51
Locking and Logging
During deletes, the database server places locks on all qualifying rows of the
referenced and referencing tables. You must turn logging on when you
perform the deletes. When logging is turned off in a database, even
tempo-rarily,
deletes do not cascade. This restriction applies because you have no
way to roll back actions if logging is turned off. For example, if a parent
row
is deleted, and the system crashes before the child rows are deleted, the
database would have dangling child records. Such records would violate
referential integrity. However, when logging is turned back on, subsequent
deletes cascade.
Will
>===== Original Message From Swapan Engineer <swapan@erols.com> =====
>Here is a simple example that I have not been able to get to work
>
>create table tab1 (k int primary key);
>create table tab2 (k int references tab1(k) on cascade delete, v int);>
>insert into tab1 values(1);
>insert into tab2 values(1,2);>
>delete from tab1 where k = 1;>
>generates the following error
>
>692: Key value for constraint (uncros.u117_57) is still being>referenced.
------------------------------------------------------------
This e-mail has been sent to you courtesy of OperaMail, as a free service from
Opera Software, makers of the award-winning Web Browser, Opera. Visit us at
http://www.opera.com/ or our portal at: http://www.myopera.com/ Your free e-mail
account is waiting at: http://www.operamail.com/
------------------------------------------------------------