Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql,v
diff -u -N -r1.43.2.2 -r1.43.2.3
--- openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql	6 Sep 2004 16:43:48 -0000	1.43.2.2
+++ openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql	21 Sep 2004 00:00:14 -0000	1.43.2.3
@@ -289,7 +289,7 @@
 
         select max(tree_leaf_key_to_int(child.tree_sortkey)) into v_max_value 
           from cr_items child
-         where child.parent_id not in (select item_id from cr_items);
+         where not exists (select 1 from cr_items where child.parent_id = item_id);
     else 
         select max(tree_leaf_key_to_int(tree_sortkey)) into v_max_value 
           from cr_items 
@@ -351,7 +351,7 @@
 
                 select max(tree_leaf_key_to_int(tree_sortkey)) into v_max_value
                   from cr_items child
-                 where child.parent_id not in (select item_id from cr_items);
+                 where not exists (select 1 from cr_items where child.parent_id = item_id);
             else 
                 select max(tree_leaf_key_to_int(tree_sortkey)) into v_max_value
                   from cr_items 
