I am moving a topic and its replies from the forum archive back to the active forum.
I have to update the post count with the replies in the FORUM and TOTALS tables.
Heres what I have now
for iReply = 0 to recReplyCount
RCatID = allReplyData(rCat_ID,iReply)
RForumID = allReplyData(rForum_ID,iReply)
RTopicID = allReplyData(rTopic_ID,iReply)
RReplyID = allReplyData(rReply_ID,iReply)
RStatus = allReplyData(rR_Status,iReply)
RAuthor = allReplyData(rR_Author,iReply)
RMessage = allReplyData(rR_Message,iReply)
RDate = allReplyData(rR_Date,iReply)
RIp = allReplyData(rR_IP,iReply)
RLastEdit = allReplyData(rR_Last_Edit,iReply)
tmpRLastEditby = allReplyData(rR_Last_Editby,iReply)
RSig = allReplyData(rR_Sig,iReply)
if isnull(tmpRLastEditby) then
RLastEditby = "NULL"
else
RLastEditby = tmpRLastEditby
end if
strRValues = "" & RCatID & ", " & RForumID & ", " & RTopicID & ", " & RReplyID & ", " & RStatus & ", " & RAuthor & ", '" & chkString(RMessage,"archive") & "', '" & RDate & "', '" & RIp & "', '" & RLastEdit & "', " & RLastEditby & ", " & RSig & " "
strsql = "INSERT INTO " & strTablePrefix & "REPLY (CAT_ID"
strSql = strSql & ", FORUM_ID"
strSql = strSql & ", TOPIC_ID"
strSql = strSql & ", REPLY_ID"
strSql = strSql & ", R_STATUS"
strSql = strSql & ", R_AUTHOR"
strSql = strSql & ", R_MESSAGE"
strSql = strSql & ", R_DATE"
strSql = strSql & ", R_IP"
strSql = strSql & ", R_LAST_EDIT"
strSql = strSql & ", R_LAST_EDITBY"
strSql = strSql & ", R_SIG)"
strsql = strsql & " VALUES (" & strRValues & ")"
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
'#### Delete From A_REPLY
strSql = "DELETE FROM " & strTablePrefix & "A_REPLY "
strSql = strSql & " WHERE REPLY_ID = " & cLng(RReplyID)
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
'## Update forum table count with reply
strSql = "UPDATE " & strTablePrefix & "FORUM"
strSql = strSql & " SET F_COUNT = F_COUNT + 1"
strSql = strSql & ", F_A_COUNT = F_A_COUNT - 1"
strSql = strSql & " WHERE FORUM_ID = " & Forum_ID
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
'## Update totals table with reply
strSql = "UPDATE " & strTablePrefix & "TOTALS "
strSql = strSql & "SET P_COUNT = P_COUNT + 1"
strSql = strSql & ", P_A_COUNT = P_A_COUNT - 1"
set rs = nothing
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
intReply = intReply + 1
next
As you can see I'm updating the counts as I move the reply and this code does work.
Would it be better to count the replies and then do the count updates after all the replies are moved?