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

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: MOD Implementation
 Needing topic id after posting new topic
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

xstream
Junior Member

242 Posts

Posted - 30 August 2002 :  14:56:12  Show Profile  Visit xstream's Homepage  Send xstream an AOL message  Send xstream an ICQ Message
Tell me if this goes in mod implementation or not. I'm working on a mod, and I'm trying to get the topic ID after it is added to the database. In the code for post_info.asp I've found the insert statement, and right after that there's a select statement on line 851 that starts with this:

strSql = "SELECT Max(TOPIC_ID) as NewTopicID "

Is it safe to use NewTopicID as that topics ID? What if someone is posting at the same time?

Normally I would just grab try to grab the id after the new topic is posted, but I'm not sure how to do that without using a recordset Object. I would normally grab it like this:

objRS.Update
new_topicid = objRS("topic_id")

Help!

Suggestions?

Xstream

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 30 August 2002 :  15:06:54  Show Profile
Yes, you should be able to use NewTopicID to get the new Topic ID.

Support Snitz Forums
Go to Top of Page

xstream
Junior Member

242 Posts

Posted - 30 August 2002 :  15:08:52  Show Profile  Visit xstream's Homepage  Send xstream an AOL message  Send xstream an ICQ Message
Thanks.

Xstream
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 30 August 2002 :  15:16:24  Show Profile  Send ruirib a Yahoo! Message
That can work, but it can also fail. Just imagine that at the same moment you posted your topic, someone else did too (it can happen, it has happened here having posts made at the same exact second). To avoid failure I would suggest that you add an extra condition:


strSql = "SELECT Max(TOPIC_ID) as NewTopicID WHERE T_AUTHOR=" & MemberID

This will get the highest topic id for your logged in member. It diminishes the chances for failure just a little bit more.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 30 August 2002 :  15:23:20  Show Profile
If you look in the 3.4 code Rui, this is the SQL statement I believe he was reffering to:
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
As you can see it also uses the FORUM_ID and the T_AUTHOR to get the TOPIC_ID. So he should be safe to go.

Support Snitz Forums
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 30 August 2002 :  15:25:47  Show Profile  Send ruirib a Yahoo! Message
Ah, thanks for that David, I didn't realize he was changing a post_info.asp.
Hmm, looks I read posts too fast .


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

xstream
Junior Member

242 Posts

Posted - 30 August 2002 :  23:00:36  Show Profile  Visit xstream's Homepage  Send xstream an AOL message  Send xstream an ICQ Message
I'm working on converting this stored procedure here http://www.sqlteam.com/item.asp?ItemID=1353 so I can have a threaded view mod for our forum. Babygate hasn't added an updated version for 3.4

So I figured I would give it a shot.

X
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.48 seconds. Powered By: Snitz Forums 2000 Version 3.4.07