SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 BTW.. Graz, perhaps a mistake here?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Carlos
Starting Member

Spain
6 Posts

Posted - 02/03/2001 :  20:44:32  Show Profile  Visit Carlos's Homepage  Reply with Quote
Hi Graz

I've been reading -well, studying!- your SQL for Threaded Discussion Forums code, and I think you missed something... or I am understing one of the steps.

To avoid pasting the same code you can find in the article, I'll tell you that the supposed mistake is, in the spPost sproc, when you're replying to a previous post, and you're doing it in the middle of a thread, you do these:
1)First, find if there are post at the same level or higher:
IF EXISTS (SELECT * FROM Posts WHERE PostLevel <=
ParentLevel AND SortOrder > @ParentSortOrder)

2)Find the next post at the same level or higher:
SELECT @NextSortOrder = Min(SortOrder)
FROM Posts
WHERE PostLevel <= @ParentLevel
AND SortOrder > @ParentSortOrder

3)Move the existing posts down.(UPDATE Posts ... )

OK, in step 2, why didn't you add (AND ThreadID = @ThreadID) to the WHERE clause? It seems to me you're searching all of the posts, not only those that belong to the current thread.

That's it, tell me I am wrong. :-)

Carlos

graz
Chief SQLTeam Crack Dealer

USA
4138 Posts

Posted - 02/04/2001 :  00:27:22  Show Profile  Visit graz's Homepage  Reply with Quote
I'd agree with you. I fixed the code and reposted. Thanks for proof reading. You were the first out of 3500+ to catch it. Keep those eagle eyes reading :)

Go to Top of Page

lundrigan
Starting Member

1 Posts

Posted - 01/28/2003 :  12:17:18  Show Profile  Reply with Quote
I was reviewing your code and I have a simple question. Why not order by threadid and postdate, wouldn't that remove the need to resort the sortorder as new message come in? Or is there something there that I am missing?


quote:

I'd agree with you. I fixed the code and reposted. Thanks for proof reading. You were the first out of 3500+ to catch it. Keep those eagle eyes reading :)

SQLTeam.com



Go to Top of Page

graz
Chief SQLTeam Crack Dealer

USA
4138 Posts

Posted - 01/28/2003 :  12:49:29  Show Profile  Visit graz's Homepage  Reply with Quote
Assume the following posts, all in thread id #1


Post 1 (Monday)
Reply 1 (Tuesday)
Reply 2 (Wednesday)



Now assume that someone replies to "Reply 1" on Thursday. I want the structure to appear as follows:


Post 1 (Monday)
Reply 1 (Tuesday)
Reply 3 (Thursday)
Reply 2 (Wednesday)





If I simply sort by date within thread, "Reply 3" will appear at the end of the list.



===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000