Click here to Skip to main content
15,888,521 members
Home / Discussions / Database
   

Database

 
GeneralRe: database Design Pin
hp10811-May-05 0:37
hp10811-May-05 0:37 
GeneralIF Statement with in Query Pin
si_6910-May-05 7:23
si_6910-May-05 7:23 
GeneralRe: IF Statement with in Query Pin
Filipe Peixinho10-May-05 7:58
Filipe Peixinho10-May-05 7:58 
GeneralRe: IF Statement with in Query Pin
Member 195262810-May-05 15:03
Member 195262810-May-05 15:03 
GeneralNeed help on this query Pin
Filipe Peixinho10-May-05 6:10
Filipe Peixinho10-May-05 6:10 
GeneralRe: Need help on this query Pin
jasncab10-May-05 14:23
jasncab10-May-05 14:23 
GeneralOracleHelper Pin
Nizar Abdeljaoued10-May-05 5:30
Nizar Abdeljaoued10-May-05 5:30 
GeneralStock Update - Database Concurrency problem Pin
crowofatlantis10-May-05 1:54
crowofatlantis10-May-05 1:54 
we are developing an ASP.NET application with SqlServer at backend..

there are an supplier and about 3000 customer, and each customer has about 3-4 users. they are selling mobile phone counters.

while a sale occurs, we are selecting customers stock amount, if it is bigger then sale amount, we are updating its stock, and we increment suppliers stock. The query is like that :

DECLARE @StockAmount int
SELECT @StockAmount = Amont FROM Stocks WHERE CustomerId = @BuyerCustomerId
IF @StockAmount > @SaleAmount
UPDATE Stocks SET amount = @StockAmount - @SaleAmount WHERE CustomerId = @BuyerCustomerId

SELECT @SuppliersStockAmount = Amont FROM Stocks WHERE CustomerId = @SellerCustomerId
UPDATE Stocks SET amount = @StockAmount + @SaleAmount WHERE CustomerId = @SellerCustomerId

i know, each customer has got not so many users and a concurrency problem seems to be not a big possibility. but there is just a 1 supplier record and i think conlicts are possible. how can i alter this problem. after a research, i found
SELECT @SuppliersStockAmount = Amont FROM Stocks WITH (XLOCK ROWLOCK) WHERE CustomerId = @SellerCustomerId

seems to work fine for us, but it will block the row untill the transaction finishes. any approaches are appreciated. thanks.
GeneralTransact SQL Pin
Anonymous10-May-05 1:54
Anonymous10-May-05 1:54 
GeneralRe: Transact SQL Pin
Colin Angus Mackay10-May-05 3:37
Colin Angus Mackay10-May-05 3:37 
GeneralRe: Transact SQL Pin
Anonymous10-May-05 21:55
Anonymous10-May-05 21:55 
GeneralDatabase schema Pin
Member 1697710-May-05 0:15
Member 1697710-May-05 0:15 
GeneralRe: Database schema Pin
Colin Angus Mackay10-May-05 0:43
Colin Angus Mackay10-May-05 0:43 
GeneralRe: Database schema Pin
Member 1697710-May-05 2:08
Member 1697710-May-05 2:08 
GeneralADO.NET output parameter Pin
Timothy_19829-May-05 20:58
Timothy_19829-May-05 20:58 
GeneralRe: ADO.NET output parameter Pin
Colin Angus Mackay9-May-05 22:49
Colin Angus Mackay9-May-05 22:49 
GeneralRe: ADO.NET output parameter Pin
Timothy_198210-May-05 0:00
Timothy_198210-May-05 0:00 
GeneralRemote query being executed multiple times Pin
alex12059-May-05 20:32
alex12059-May-05 20:32 
GeneralProblem to search with a hyphen Pin
Nik_Pick9-May-05 10:16
Nik_Pick9-May-05 10:16 
Questionsql server 2000 documentor? Pin
WDI9-May-05 10:14
WDI9-May-05 10:14 
AnswerRe: sql server 2000 documentor? Pin
-Dr_X-10-May-05 10:10
-Dr_X-10-May-05 10:10 
GeneralNewbie help VS2003, SQLDataAdapter and Update Pin
Richard Schaefer9-May-05 9:19
Richard Schaefer9-May-05 9:19 
Generalunderstading if there is data inside a row filed Pin
Sasuko9-May-05 4:06
Sasuko9-May-05 4:06 
GeneralRe: understading if there is data inside a row filed Pin
Dave Kreskowiak9-May-05 5:37
mveDave Kreskowiak9-May-05 5:37 
Generalmy database is not case sensitive Pin
Sasuko9-May-05 3:48
Sasuko9-May-05 3:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.