Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2006, 09:47 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

Hi robprell,

Thanks for the reply.

After some help in this forum, I figured out how to do the counter. My only problem now is to make sure that I will not have a concurrency issue using the code above.

I also would like to understand what a deadlock is?

Cheers
 
Old December 6th, 2006, 03:03 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

 
Quote:
quote:as long as all accesses to acquire an order number are done in the same way


That's the problem Jeff... no body pays attention to that little nuance...

--Jeff Moden
 
Old December 6th, 2006, 03:05 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

 
Quote:
quote:Could you please answer my previous message. Do you think I am safe with this code?
Quote:
No... you have an IDENTITY column... why are you using a SEQUENCE table like this? Do an insert from your GUI and use SCOPE_IDENTITY to find what the ID of the new row is.

--Jeff Moden
 
Old December 6th, 2006, 12:01 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

Hi Jeff,

I think my explanation was not clear. I do not need to touch the IDENTITY field at all. This is used to give the company an unique id.

What I am working towards is to build a counter of insertions (but not of companies) which will be store in the same table.

So, for example, before any user from company with IDENTITY 1 makes an advertisement insertion in the adds table, I have to incremente this counter in the company table and return it so that this counter number is inserted in the other table as well.

This has nothing to do with creating IDs.

So, if another user from company 2 makes an add insertion in the adds table, before that I have to go again to the table company increment the counter fiels and get the number back to be inserted together with the add in the add table.

That is why in my stored procedure I am using this sql statement to retrieve the updated counter. Then I will use this number to insert the add in the add table.

UPDATE tblCompany SET @NextON = NextOrderNumber = NextOrderNumber + 1
WHERE CompanyID = @CompanyId

Therefore, I have to make sure this code will not cause any concurrency issues since two users from the same company could make a call at the same time.

After I receive the value from the @NextON output parameter I will use to insert to the add table

Insert into tblAdds (NextCounterNumber, AdDetail, Date)
values( NextON, '...', date)

Please could shed some light?

Cheers,

CPALL





Similar Threads
Thread Thread Starter Forum Replies Last Post
concurrency problems Dorean Visual Studio 2005 1 September 4th, 2007 10:38 AM
Concurrency issues vitthala ASP.NET 2.0 Basics 3 October 18th, 2006 11:42 AM
Concurrency problem sanjaymannnet ASP.NET 1.0 and 1.1 Professional 0 July 10th, 2006 05:42 AM
Concurrency Issue billy_bob_the_3rd Classic ASP Components 1 October 23rd, 2004 09:33 AM
Concurrency dextertoh Classic ASP Databases 2 May 17th, 2004 12:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.