Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Updating a table field depending on current value

Author  Topic 

harlingtonthewizard
Constraint Violating Yak Guru

352 Posts

Posted - 2008-08-05 : 02:56:42
I have the following code however it does not work. I select the last row in a table (this works) and then depending on the value of the InterActionFlag field value(busy or ready) do the following. If ready update InterActionFlag to busy, if busy wait until it is ready.

ALTER PROCEDURE dbo.Update1

AS
BEGIN
/* SET NOCOUNT ON */
SELECT PutToArchiveID, PutToArchiveProgressStatus, PutToArchiveStartTime, PutToArchiveEndTime, IsolationTimePoint, MakeVCReadOnlyTime, StopVCTime, RestartVCTime, InterActionFlag,
CASE
WHEN InterActionFlag = 'Ready'
THEN UPDATE VCLog.dbo.PutToArchiveLog SET VCLog.dbo.PutToArchiveLog.InterActionFlag='BUSY'
WHEN InterActionFlag = 'Busy'
THEN Wait
END
FROM (SELECT PutToArchiveID, PutToArchiveProgressStatus, PutToArchiveStartTime, PutToArchiveEndTime, IsolationTimePoint, MakeVCReadOnlyTime, StopVCTime, RestartVCTime, InterActionFlag
FROM VCLog.dbo.PutToArchiveLog
WHERE PutToArchiveID IN
(SELECT MAX(PutToArchiveID) FROM VCLog.dbo.PutToArchiveLog)) AS LastRowDetails
END

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-08-05 : 03:05:33
I've never heard that SQL-Statements can WAIT.
What is about Trigger?

Webfred
Go to Top of Page
   

- Advertisement -