Index: openacs-4/packages/forums/sql/oracle/forums-messages-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-messages-package-create.sql,v diff -u -r1.10 -r1.10.2.1 --- openacs-4/packages/forums/sql/oracle/forums-messages-package-create.sql 15 Mar 2005 20:06:45 -0000 1.10 +++ openacs-4/packages/forums/sql/oracle/forums-messages-package-create.sql 2 Jan 2006 00:24:30 -0000 1.10.2.1 @@ -328,6 +328,7 @@ ) is v_cur forums_messages%ROWTYPE; + v_last_child_post forums_messages.last_child_post%TYPE; begin select * into v_cur @@ -346,12 +347,23 @@ end if; else if state = 'approved' and v_cur.state <> 'approved' then - update forums_messages - set approved_reply_count = approved_reply_count + 1, - last_poster = (case when v_cur.posting_date > last_child_post then v_cur.user_id else last_poster end), - last_child_post = (case when v_cur.posting_date > last_child_post then v_cur.posting_date else last_child_post end) - where forum_id = v_cur.forum_id - and tree_sortkey = tree.ancestor_key(v_cur.tree_sortkey, 1); + select last_child_post into v_last_child_post + from forums_messages + where forum_id = v_cur.forum_id + and tree_sortkey = tree.ancestor_key(v_cur.tree_sortkey, 1); + if v_cur.posting_date > v_last_child_post then + update forums_messages + set approved_reply_count = approved_reply_count + 1, + last_poster = v_cur.user_id, + last_child_post = v_cur.posting_date + where forum_id = v_cur.forum_id + and tree_sortkey = tree.ancestor_key(v_cur.tree_sortkey, 1); + else + update forums_messages + set approved_reply_count = approved_reply_count + 1 + where forum_id = v_cur.forum_id + and tree_sortkey = tree.ancestor_key(v_cur.tree_sortkey, 1); + end if; elsif state <> 'approved' and v_cur.state = 'approved' then update forums_messages set approved_reply_count = approved_reply_count - 1 Index: openacs-4/packages/forums/sql/oracle/upgrade/upgrade-1.2d1-1.2d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/upgrade/upgrade-1.2d1-1.2d2.sql,v diff -u -r1.1 -r1.1.2.1 --- openacs-4/packages/forums/sql/oracle/upgrade/upgrade-1.2d1-1.2d2.sql 15 Mar 2005 20:06:45 -0000 1.1 +++ openacs-4/packages/forums/sql/oracle/upgrade/upgrade-1.2d1-1.2d2.sql 2 Jan 2006 00:24:30 -0000 1.1.2.1 @@ -370,6 +370,7 @@ ) is v_cur forums_messages%ROWTYPE; + v_last_child_post forums_messages.last_child_post%TYPE; begin select * into v_cur @@ -388,12 +389,23 @@ end if; else if state = 'approved' and v_cur.state <> 'approved' then - update forums_messages - set approved_reply_count = approved_reply_count + 1, - last_poster = (case when v_cur.posting_date > last_child_post then v_cur.user_id else last_poster end), - last_child_post = (case when v_cur.posting_date > last_child_post then v_cur.posting_date else last_child_post end) - where forum_id = v_cur.forum_id - and tree_sortkey = tree.ancestor_key(v_cur.tree_sortkey, 1); + select last_child_post into v_last_child_post + from forums_messages + where forum_id = v_cur.forum_id + and tree_sortkey = tree.ancestor_key(v_cur.tree_sortkey, 1); + if v_cur.posting_date > v_last_child_post then + update forums_messages + set approved_reply_count = approved_reply_count + 1, + last_poster = v_cur.user_id, + last_child_post = v_cur.posting_date + where forum_id = v_cur.forum_id + and tree_sortkey = tree.ancestor_key(v_cur.tree_sortkey, 1); + else + update forums_messages + set approved_reply_count = approved_reply_count + 1 + where forum_id = v_cur.forum_id + and tree_sortkey = tree.ancestor_key(v_cur.tree_sortkey, 1); + end if; elsif state <> 'approved' and v_cur.state = 'approved' then update forums_messages set approved_reply_count = approved_reply_count - 1