Index: openacs-4/contrib/obsolete-packages/bboard/sql/postgresql/bboard-packages.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard/sql/postgresql/bboard-packages.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/obsolete-packages/bboard/sql/postgresql/bboard-packages.sql	24 Sep 2001 23:45:12 -0000	1.3
+++ openacs-4/contrib/obsolete-packages/bboard/sql/postgresql/bboard-packages.sql	1 Dec 2001 22:25:53 -0000	1.4
@@ -502,16 +502,15 @@
     image_p integer;
     v_search_key varchar;
 begin
-    select tree_sortkey || ''%'' into v_search_key
+    select into v_search_key
       from acs_messages
      where message_id = thread_id;
 
     for child_val in 
         select object_id as child_id, object_type
-          from acs_objects
-         where context_id in (select message_id 
-                                from acs_messages
-                               where tree_sortkey like v_search_key)
+          from acs_objects o, acs_messages m
+         where o.context_id = m.message_id 
+           and m.tree_sortkey between v_search_key and tree_right(v_search_key)
     loop
         if child_val.object_type = ''acs_message'' then
            perform acs_message__delete(child_val.child_id);
@@ -530,7 +529,7 @@
     for message_val in 
         select message_id
 	  from acs_messages
-         where tree_sortkey like v_search_key
+         where tree_sortkey between v_search_key and tree_right(v_search_key)
     loop
         perform acs_message__delete(message_val.message_id);
     end loop;
