Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Help with SQL - New Topic
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

StephenD
Senior Member

Australia
1044 Posts

Posted - 21 August 2005 :  02:18:56  Show Profile  Send StephenD a Yahoo! Message  Reply with Quote
I've got a custom table in my snitz db that I need to link to the Topics table by TOPIC_ID. How do I pass the TOPIC_ID in an INSERT INTO NEWTABLE statement .. the same time the topic or TOPIC_ID is created in post_info.asp?<

Etymon
Advanced Member

United States
2385 Posts

Posted - 23 August 2005 :  05:00:25  Show Profile  Visit Etymon's Homepage  Reply with Quote
quote:
Originally posted by StephenD

I've got a custom table in my snitz db that I need to link to the Topics table by TOPIC_ID. How do I pass the TOPIC_ID in an INSERT INTO NEWTABLE statement .. the same time the topic or TOPIC_ID is created in post_info.asp?



Hi Stephen,

Look in post_info.asp for NewTopicID

In Snitz 3.4.05 the code looks like this:


		strSql = "SELECT Max(TOPIC_ID) as NewTopicID "
		strSql = strSql & " FROM " & strActivePrefix & "TOPICS "
		strSql = strSql & " WHERE FORUM_ID = " & Forum_ID
		strSql = strSql & "   and T_AUTHOR = " & rs("MEMBER_ID")
		set rs9 = my_Conn.Execute (strSql)
		NewTopicID = rs9("NewTopicID")
		rs9.close
		set rs9 = nothing

		' DEM --> Do not update forum count if topic is moderated.... Added if and end if
        	if Moderation = "No" then
			'## Forum_SQL - Increase count of topics and replies in Forum table by 1
			strSql = "UPDATE " & strTablePrefix & "FORUM "
			strSql = strSql & " SET F_LAST_POST = '" & DateToStr(strForumTimeAdjust) & "'"
			strSql = strSql & ",    F_TOPICS = F_TOPICS + 1"
			strSql = strSql & ",    F_COUNT = F_COUNT + 1"
			strSql = strSql & ",    F_LAST_POST_AUTHOR = " & rs("MEMBER_ID") & ""
			strSql = strSql & ",    F_LAST_POST_TOPIC_ID = " & NewTopicID
			strSql = strSql & ",    F_LAST_POST_REPLY_ID = " & 0
			strSql = strSql & " WHERE FORUM_ID = " & Forum_ID
			my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
		end if


Apply your INSERT using NewTopicID anywhere after set rs9 = nothing.

However, that recordset was created within an if/end if statement which is if MethodType = "Topic" then/end if.

Either apply your INSERT within that if/end if and somewhere after set rs9 = nothing (During testing, I would try it before the ProcessSubscriptions call since that evokes the inc_mail.asp file, which could possibly lead you down another trail), or apply it after the end if (referring to if MethodType = "Topic" then/end if statement that set rs9 = nothing is in) by using your own if MethodType = "Topic" then/end if statement just before if MethodType = "Reply" or MethodType = "ReplyQuote" or MethodType = "TopicQuote" then.

Again, I would place it above ProcessSubscriptions during testing and then do a Response.Write strSql after the my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords from the INSERT command to verify that the NewTopicID got sent to the custom table.


Cheers,

Etymon
<
Go to Top of Page

StephenD
Senior Member

Australia
1044 Posts

Posted - 23 August 2005 :  05:37:03  Show Profile  Send StephenD a Yahoo! Message  Reply with Quote
Thank you Etymon for the detailed answer. I'll give it a shot later tonight.
Cheers.
<
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000 Version 3.4.07