|
OK, tried everything..
1. I am using "scope_identity()"
instead of @@IDENTITY - I knew this was not the problem as it returned the
correct identity before, however I am using it now, as it sounds like a
better option.
2. Checked the value of @bError and its
definately set to 0 at the end, so a COMMIT should be fired.
Checked the lock processes, but nothing out of
the ordinary.
3. Removed the full-text catalog indexing from
the SP
Still getting the same problem. Funny thing is
though, if I execute the same code through the SQL Query Analyzer it executes
fine without any delay...
I have just now noticed
though, that the insert is immediate i.e. as soon as I post the page the record
is inserted, however the select statement that should return the new record to
the client again does not retrieve it.
hhmmm, locking or transaction
issue??
Tried something new, I removed the
TRANSACTION statements,
however still the same, so it's not a transaction issue. All thats left is a
locking issue I beleive, but where and how??
CREATE PROCEDURE spForumThreadInsert
( @categoryID INTEGER, @header VARCHAR(200), @threadBody VARCHAR(8000), @someoneID INTEGER, @startDate SMALLDATETIME = NULL, @expiryDate SMALLDATETIME = NULL, @newThreadID INTEGER = NULL OUTPUT, @bApprovalRequired BIT = NULL OUTPUT, @bError BIT = NULL OUTPUT ) AS SET @bError = 0
--BEGIN TRANSACTION
DECLARE @bApproved
BIT
SET @bApprovalRequired =
(SELECT approvalRequired FROM tblForumCategory WHERE (pkCategoryID =
@categoryID))
IF @bApprovalRequired = 0 BEGIN SET @bApproved = 1 END ELSE BEGIN SET @bApproved = 0 END IF @startDate IS
NULL
SET @startDate = GETDATE() INSERT
INTO tblForumThread
(fkCategoryID, fkSomeoneID, threadHeader, threadBody, fkStatusID, startDate, expiryDate) VALUES (@categoryID, @someoneID, @header, @threadBody, @bApproved, @startDate, @expiryDate) -- Check if there are any errors IF NOT (@@ERROR = 0) BEGIN SET @bError = 1 END SET @newThreadID = SCOPE_IDENTITY() -- Update category statistics, i.e. thread count UPDATE tblForumCategory SET threadCount = threadCount + 1 WHERE (pkCategoryID = @categoryID) -- Check if there are any errors IF NOT (@@ERROR = 0) BEGIN SET @bError = 1 END /*
IF @bError = 1
BEGIN -- Rollback transaction if there was an error ROLLBACK TRANSACTION END ELSE BEGIN -- Commit transaction if there was no error COMMIT TRANSACTION END PRINT @bError */
IF @bError = 0
BEGIN -- Update count of records added to full-text search tables UPDATE tblSystemVariable SET variableInteger = variableInteger + 1, variableDate = GETDATE() WHERE (variableName = 'fullTextCount') END GO --- You are currently subscribed to cfaussie as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] MX Downunder AsiaPac DevCon - http://mxdu.com/ |
Title: Message
- [cfaussie] RE: Slow insert with SP ??? John Reed
- [cfaussie] RE: Slow insert with SP ??? Taco Fleur
- [cfaussie] RE: Slow insert with SP ??? John Reed
- [cfaussie] RE: Slow insert with SP ??? Taco Fleur
- [cfaussie] RE: Slow insert with SP ??? Taco Fleur
- [cfaussie] RE: Slow insert with SP ??? John Reed
- [cfaussie] RE: Slow insert with SP ??? Taco Fleur
