The invention relates to the field of database technology, in particular to a method for generating business order number. The method steps of the invention are as follows: 1, create a self growth record table AutoIncrement; 2, implement a stored procedure uspGetAutoIncrement that does not repeat ID in the same day according to the different service types; 3, implement a function Lpad that is filled with the specified character according to the specified length; 4, and invoke the stored procedure uspGetAutoIncrement to get ID; 5, call The function Lpad fills in \0\ to the left of the resulting ID; 6. Connects the business prefix with the day date string and ID to get the business order number. The invention solves the problem that the length of database self growth ID is not uniform, and the date information is not readable.
【技术实现步骤摘要】
一种业务订单号生成方法
本专利技术涉及数据库
,具体涉及一种业务订单号生成方法。
技术介绍
目前自增长ID作为数据的唯一标记正被大量使用。但自增长ID长度不统一,不包含业务信息和日期信息,可读性差。
技术实现思路
本专利技术解决的技术问题在于提供一种业务订单号生成方法,解决了原来自增长工D长度不统一,不包含业务信息和日期信息,可读性差的问题。本专利技术解决上述技术问题的技术方案是:所述的方法包括以下步骤:步骤一、创建自增长记录表AutoIncrement;步骤二、实现根据不同业务类型生成当天内不重复ID的存储过程uspGetAutoIncrement,在存储过程中启用事务;步骤三、实现根据指定长度左填充指定字符的函数Lpad;步骤四、调用存储过程uspGetAutoIncrement得到ID;步骤五、调用函数Lpad对得到的ID左填充“0”;步骤六、将业务前缀加上当天日期字符串和ID连接起来得到业务订单号;本专利技术的有益效果:根据数据库事务会锁定表的特点,首先利用存储过程生成ID,存储过程中启用了事务,生成ID过程中,自增长记录表会被锁定,所以生成的ID在当天中不会重复,ID再和业务前缀和日期字符串拼接起来得到业务订单号,从而达到保证生成不重复、包含业务前缀和日期、可读性好的业务订单号的目的。附图说明下面结合附图对本专利技术进一步说明:图1为本专利技术的方法流程图。具体实施方式如图1所示,本专利技术采用如下步骤:步骤一、创建自增长记录表AutoIncrement;如:GuidTypeValueUpdateTimeGuid业务类型值更新时间步骤二、实现根 ...
【技术保护点】
1.一种业务订单号生成方法,其特征在于:所述的方法包括以下步骤:步骤一、创建自增长记录表AutoIncrement;步骤二、实现根据不同业务类型生成当天内不重复ID的存储过程uspGetAutoIncrement,在存储过程中启用事务;步骤三、实现根据指定长度左填充指定字符的函数Lpad;步骤四、调用存储过程uspGetAutoIncrement得到ID;步骤五、调用函数Lpad对得到的ID左填充“0”;步骤六、将业务前缀加上当天日期字符串和ID连接起来得到业务订单号。
【技术特征摘要】
1.一种业务订单号生成方法,其特征在于:所述的方法包括以下步骤:步骤一、创建自增长记录表AutoIncrement;步骤二、实现根据不同业务类型生成当天内不重复ID的存储过程uspGetAutoIncrement,在存储过程中启用事务;...
【专利技术属性】
技术研发人员:张伟荣,季统凯,
申请(专利权)人:国云科技股份有限公司,
类型:发明
国别省市:广东,44
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。