SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 27th, 2000, 08:16 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
locking SQL Server or UID Gen

<i><b>Originally posted by : eric (e)</b></i><br />Please see sample code below....<br />Is there a way to lock the MSSQL server so that when I execute the first request it will lock and update by one then when I run my SELECT I will get the updated number. I am having the problem that if one user has just executed the UPDATE statement and another user executes an UPDATE when they execute the SELECT they both receive the same number. Im looking for a way to serialize the commands or lock the DB when the first UPDATE is executed then unlock the DB after the SELECT is done. Can this be done with one staement? Or is there a Microsoft way of doing<br />"SELECT GEN_ID( myDB, inc val) FROM RDB$DATABASE"<br />Im just trying to use SQL as a UID generator that will increment by 1 when it is called.<br />Thanks<br />Eric<br />sqlCmd = "UPDATE thetest SET thetest.thecounter = thetest.thecounter + 1 "<br />openLog.Execute sqlCmd <br />sqlCmd = "SELECT thetest.thecounter FROM thetest WHERE thetest.id = 12" <br />Set msg = openLog.Execute( sqlCmd ) <br />number = msg("thecounter")<br /><br /><br />

Reply With Quote
  #2  
Old October 14th, 2003, 12:03 PM
m_lazor m_lazor is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Luxembourg
Posts: 156 m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Not a lock pb. Best is use a stored proc and a table with an AutoNumber (Identity) column. Then just after the insert add

SELECT MyID = @@IDENTITY

MyID will contain the ID of the new record

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > locking SQL Server or UID Gen


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT