[sql]高度自定义的自动生成列。 [英] [Sql] highly customized auto generated column.

查看:55
本文介绍了[sql]高度自定义的自动生成列。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个让我在SQL Server上工作的项目。下一个功能是:



在序列号插入时,SQL Server必须返回N个MAC地址。

这些MAC地址值取决于序列号值。



对于给定的序列号,返回的N个MAC地址必须在范围(或几个工会的联合)。



此外,这些MAC地址必须是连续的请求。重要的是要知道可以同时打开多个会话,因此可以同时发出多个请求。



您能帮我确定哪个会话我应该工作的对象。交易,功能,触发器,存储过程?



谢谢大家。



我是什么尝试过:



我搜索了很多类似的问题,但我找不到类似的东西。

解决方案

根据你的问题的标题([Sql]高度自定义的自动生成列)我相信你有一个错误的方法。如果您需要一组具有单个调用的MAC地址,则无法将逻辑绑定到单个行中。您需要创建一个函数或存储过程来创建一组所需的地址,并将它们存储在需要的地方。



由于可能涉及多个陈述,您应该将整个操作包含在一个事务中,以确保从一个一致状态移动到另一个状态。



程序或函数内部的逻辑是什么,这取决于确切的要求,但我建议将问题分解成更小的部分并尝试逐个解决它们。

Hi,

I have a project that brings me to work on SQL Server. A functionality is the next one:

On a serial number insertion, the SQL Server has to return N number of MAC addresses.
Those MAC addresses values are depending on the serial number value.

For a given serial number the returned N MAC addresses have to be in a range (or union of several unions).

Moreover those MAC adresses have to be consecutive for a request. It's important to know that several sessions could be opened at the same time, so multiple request can occur at the same time.

Could you please help me to determine with which objects I should work. Transactions, functions, triggers, stored procedure ?

Thank you all.

What I have tried:

I searched for a lot of similar problems, but I don't manage to find something comparable.

解决方案

Based on the title of your question ([Sql] highly customized auto generated column) I believe that you have a wrong approach. If you need a set of MAC addresses with single call you cannot bind the logic into a single row. You need to create for example a function or stored procedure to create the set of needed addresses and store those wherever they need to be.

Since several statement are probably involved you should wrap the whole operation inside a transaction in order to ensure movement from one consistent state to another.

What comes to the logic inside the procedure or function, that's up to the exact requirements, but I suggest breaking the problem into smaller pieces and trying to solve them one-by-one.


这篇关于[sql]高度自定义的自动生成列。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆