什么是自动起泡的最佳方法

编程入门 行业动态 更新时间:2024-10-27 00:35:21
本文介绍了什么是自动起泡的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Sql Server 2008 R2在C#中构建队列管理系统.一次在许多部门提供服务,例如客户服务部,女士部,注册部.例如.对于

I am building a Queue Management System in C# using Sql Server 2008 R2. Providing Services in many departments at a time Like Customer Care, Ladies Section, Registration Section. For Example. For

  • 女士专区:令牌{1-50}
  • 客户服务:令牌{51-350}
  • 注册科:令牌{351-550}
  • 普通客户:令牌{551-999}

我正在使用这种方法,首先,我正在从哪个部门获得请求.在表中检查该部门的令牌范围,然后获取该部门的令牌的现有值.使用更新下一个号码"表覆盖现有值.

I am using this Approach, First of all i am looking from which department I am getting request. Check Token Range of this department in Table, then getting existing value of the Token for this department. Overriding existing value with Updating Next Number table.

我是否可以使用其他方法,因为我遇到的问题是,正常客户/注册/客户/女士部分的两个屏幕上有时会出现相同的令牌编号.

Is there any other approach i can use because i am facing problem that sometimes same Token Number is coming on Two Screens of Normal Customer's/Registration/Customer/Ladies Sections.

谢谢

推荐答案

您可以对输出语句使用update,如下所示:

You could use update with output statement, like this:

use tempdb go if object_id('Tokens', 'u') is not null drop table Tokens if object_id('GetNextToken', 'p') is not null drop procedure GetNextToken go create table Tokens ( Id int identity(1,1) not null, Name varchar(50) not null, TokenFrom int not null, TokenTo int not null, LastUsedToken int null, constraint PK_Tokens primary key clustered (Id), constraint UQ_Tokens_Name unique (Name) ) go insert into Tokens (Name, TokenFrom, TokenTo) select 'Ladies Section', 1, 50 union select 'Customer Care', 51, 350 union select 'Registration Section', 351, 550 union select 'Normal Customers', 551, 999 go create procedure GetNextToken @name varchar(50), @token int output as begin declare @tokens table (token int) update Tokens set LastUsedToken = case when LastUsedToken is null then TokenFrom when LastUsedToken = TokenTo then TokenFrom else LastUsedToken + 1 end output inserted.LastUsedToken into @tokens where Name = @name set @token = (select top 1 token from @tokens) end go -- To get 'Ladies Section' declare @name varchar(50), @token int set @name = 'Ladies Section' exec GetNextToken @name, @token output select @token go -- To get 'Customer Care' declare @name varchar(50), @token int set @name = 'Customer Care' exec GetNextToken @name, @token output select @token go -- To get 'Registration Section' declare @name varchar(50), @token int set @name = 'Registration Section' exec GetNextToken @name, @token output select @token go -- To get 'Normal Customers' declare @name varchar(50), @token int set @name = 'Normal Customers' exec GetNextToken @name, @token output select @token

更多推荐

什么是自动起泡的最佳方法

本文发布于:2023-10-27 02:46:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532075.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!