Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql,v
diff -u -r1.40 -r1.41
--- openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql	17 May 2003 01:47:10 -0000	1.40
+++ openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql	24 Aug 2003 00:27:45 -0000	1.41
@@ -418,6 +418,8 @@
 create or replace function acs_objects_context_id_up_tr () returns opaque as '
 declare
         pair    record;
+        outer record;
+        inner record;
         security_context_root integer;
 begin
   if new.object_id = old.object_id and
@@ -427,13 +429,15 @@
   end if;
 
   -- Remove my old ancestors from my descendants.
-  delete from acs_object_context_index
-  where object_id in (select object_id
-                      from acs_object_contexts
-                      where ancestor_id = old.object_id)
-  and ancestor_id in (select ancestor_id
-		      from acs_object_contexts
-		      where object_id = old.object_id);
+  for outer in select object_id from acs_object_context_index where 
+               ancestor_id = old.object_id and object_id <> old.object_id loop
+    for inner in select ancestor_id from acs_object_context_index where
+                 object_id = old.object_id loop
+      delete from acs_object_context_index
+      where object_id = outer.object_id
+        and ancestor_id = inner.object_id;
+    end loop;
+  end loop;
 
   -- Kill all my old ancestors.
   delete from acs_object_context_index
