Index: openacs-4/packages/forums/sql/oracle/forums-reading-info-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-reading-info-package-create.sql,v
diff -u -N -r1.3 -r1.4
--- openacs-4/packages/forums/sql/oracle/forums-reading-info-package-create.sql	10 Nov 2017 17:21:05 -0000	1.3
+++ openacs-4/packages/forums/sql/oracle/forums-reading-info-package-create.sql	13 Nov 2017 15:22:26 -0000	1.4
@@ -128,13 +128,15 @@
 
         end user_add_msg;
 
+
 -- move message to other thread
 	procedure move_thread_update (
 		p_source_message_id in forums_messages.message_id%TYPE,
 		p_target_message_id in forums_messages.message_id%TYPE
 	) is
 		v_target_forum_id 			forums_forums.forum_id%TYPE;
 		v_users             			forums_reading_info%ROWTYPE;
+                v_source_root_message_id 		forums_messages.message_id%TYPE;
 	begin
             begin
                 select forum_id into v_target_forum_id from forums_messages where message_id = p_target_message_id;
@@ -143,16 +145,25 @@
                      v_target_forum_id := null;
             end;
 
-
-		for v_users in (select user_id from forums_reading_info fri where root_message_id  = p_target_message_id and not exists(select 1 from forums_reading_info where root_message_id = p_source_old_root_message_id and user_id = fri.user_id))
+                select root_message_id from forums_forums
+                 where forum_id = (select forum_id from forums_messages
+                                    where message_id = p_source_message_id) into v_source_root_message_id;
+                        
+		for v_users in (
+                    select user_id from forums_reading_info fri
+                     where root_message_id = p_target_message_id
+                       and not exists (select 1 from forums_reading_info
+                                        where root_message_id = v_source_old_root_message_id
+                                          and user_id = fri.user_id))
 		loop
-
-			delete from forums_reading_info where root_message_id = p_target_message_id and user_id = v_users.user_id;
-			-- down the number of threads read in target forum
+			delete from forums_reading_info
+                         where root_message_id = p_target_message_id
+                           and user_id = v_users.user_id;
 		end loop;
 
 	end move_thread_update;
 
+
 end forum_reading_info;
 /
 show errors
