sql - Update with Priority -
here request:
update top (1) innerportal.feedback.queuefeedback set busy = 1, busyby = @uid output inserted.* ( accountcode = @account , (done null or done = 0) , (busy null or busy = 0) , ((datepart(hour, dateadd(hour, utc, @utcnow)) >= 9 ) , (datepart(hour, dateadd(hour, utc, @utcnow)) <= 20)) )
it gets first founded "non busy" record key field accountcode
.
if record not found request returns nothing.
next have ordered list of accountcode
, target release special logic:
need create loop in request.
first accountcode
list , try update.
- if success - stop , return
output inserted.*
- if update not successful request second entry accounts list , try update again.
if loop on , nothing updated - output inserted.*
returns nothing (like now).
possible release in single request? thanks!
update top (1) innerportal.feedback.queuefeedback
set busy = 1, busyby = @uid output inserted.* innerportal.feedback.queuefeedback join account on accountcode = account.id , accountcode = @account , (done null or done = 0) , (busy null or busy = 0) , ( (datepart(hour, dateadd(hour, utc, @utcnow)) >= 9 ) , (datepart(hour, dateadd(hour, utc, @utcnow)) <= 20) )
Comments
Post a Comment