需要帮助生成订单号 [英] Need help in generating order Number

查看:87
本文介绍了需要帮助生成订单号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



在我的表格中(表格设置)我有3列

前缀

后缀并且

序列号



现在在我的订单中,我必须添加此3并生成订单号

例如ORD-2001-XYZ

因此对于每个订单只有Seri​​alNo即2001将增加。

请告诉我该怎么做..



现在我做的是我有3个sql查询,我将每个结果存储在一个变量中,最后做这样的事情



< pre lang =vb> Dim concat As String = a + - + c + - + b



并将值分配给OrderNo文本框。



但是接下来的记录它将无法工作..



所以请告诉我如何增加数字每次都值。



谢谢你

解决方案

两个想法(既然你不说哪个DB你'重新使用我不能更具体)



1)而不是SerialNo p er se(或甚至在另一个表中)有一个自动增量整数主键 - 每次插入表中,并选择最高记录的键/ ID以获得下一个'SerialNo',转换为字符串并修剪为所需的数字你需要 - 缺点是桌子增长



2)使用触发器/程序增加值



3)Oracle:使用序列



'g'


看到: http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server [ ^ ]



问候..


Hi all

In my table(Form Settings) i have 3 columns
Prefix
Suffix and
SerialNo

Now in my Order from i have to add this 3 and generate Order Number
e.g. ORD-2001-XYZ
so for each order only SerialNo i.e 2001 will increment.
Please tell me how to do this..

Now what i did is i have 3 sql query and i stored the result for each in a variable and at end doing like this

Dim concat As String = a + "-" + c + "-" + b


and assigning the value to OrderNo textbox.

But next record it will not work..

So please tell me how to increment the Number Value each time.

Thank you

解决方案

Two thoughts (since you dont say which DB you're using I cant be more specific)

1) instead of SerialNo per se (or even in another table) have an auto increment integer primary key - insert into the table every time, and select the highest record's key/ID to get the next 'SerialNo', with conversion to string and trim to the required digits you require - the cons are the table grows

2) use a trigger/procedure to increment a value

3) Oracle : use a sequence

'g'


See this : http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server[^]

Regards..


这篇关于需要帮助生成订单号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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