ERP基础档案管理模块中实现多级分类档案ID号自动编码技术(V1.0)
来源:互联网 发布:网络视频帧数是多少 编辑:程序博客网 时间:2024/05/16 03:25
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
ERP基础档案管理模块中实现多级分类档案ID号自动编码技术(V1.0)
本存储过程实现了多级分类档案ID号自动编码技术,本版本(V1.0)现在只实现每级3位的编码,
本版本的特点是:
n 可以根据不同的表产生不同的编码,达到通用化
n 调用时通过指定iIsSubNode要产生的节点编码是否是子结点还是兄弟节点来生成对应编码
进行调用本存储过程时需要注意的是需要传递节点的层次(或是叫节点的深度)
另外下一个版本(V2.0)将根据用户自定义每级长度来实现更灵活的自动编码技术。
CREATEprocedureprcIDAutoGen
@vSourceIDvarchar(30),
@IDepthint,
@iIsSubNodeint,
@Tablevarchar(20),
@vIncrementvarchar(30)output
as
begin
declare@iLenint
declare@vTempIDvarchar(30)
declare@SQLStringnvarchar(500)
if@iIsSubNode=1
begin
set@IDepth=@IDepth+1
set@iLen=@IDepth*3
set@SQLString=N'selectvIDfrom'+@Table+'wherevID='''+ltrim(rtrim(@vSourceID))+''''
exec(@SQLString)
if@@rowcount>0
begin
select@vSourceIDasvIDinto#t
set@SQLString=N'insert#tselectvIDfrom'+@Table+'wherevParentIDin(selectvIDfrom#t) andvIDnotin(selectvIDfrom#t)andIDepth=@IDepth'
execsp_executesql@SQLString,N'@IDepthint',@IDepth
if@@rowcount>0
begin
set@SQLString=N'select @vTempID=isnull(max(vID),''0'')from#t'
execsp_executesql@SQLString,N'@vTempIDvarchar(30)output',@vTempID output
set@SQLString='select@vIncrement=right(''000''+cast((cast(substring(@vTempID,1,@iLen)asdecimal(30,0))+1)asvarchar),@iLen)'
execsp_executesql@SQLString,N'@vIncrementvarchar(30)output,@vTempIDvarchar(30),@iLenint',@vIncrementout,@vTempID,@iLen
end
else
begin
select @vIncrement=ltrim(rtrim(@vSourceID))+'001'
end
end
else
begin
select@vIncrement='001'
end
end
else
begin
set@iLen=len(ltrim(rtrim(@vSourceID)))
set@SQLString=N'selectvIDfrom'+@Table+'wherevID='''+ltrim(rtrim(@vSourceID))+''''
exec(@SQLString)
if@@rowcount>0
begin
set@SQLString=N'select @vTempID=isnull(max(vID),''0'')from'+@Table+'wherevIDin(selectvIDfrom'+@Table+'whereIDepth=@IDepth)'
execsp_executesql@SQLString,N'@vTempIDvarchar(30)output,@IDepthint',@vTempID output,@IDepth
set@SQLString='select@vIncrement=right(''000''+cast((cast(substring(@vTempID,1,@iLen)asdecimal(30,0))+1)asvarchar),@iLen)'
execsp_executesql@SQLString,N'@vIncrementvarchar(30)output,@vTempIDvarchar(30),@iLenint',@vIncrementout,@vTempID,@iLen
end
else
begin
select@vIncrement='001'
end
end
end
用户创建基础档案时可以按以下类似表格式创建:
createtableCustomerClass(
vID varchar(30)constraintpkCustomerClassprimarykey,1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
ERP基础档案管理模块中实现多级分类档案ID号自动编码技术(V1.0)
本存储过程实现了多级分类档案ID号自动编码技术,本版本(V1.0)现在只实现每级3位的编码,
本版本的特点是:
n 可以根据不同的表产生不同的编码,达到通用化
n 调用时通过指定iIsSubNode要产生的节点编码是否是子结点还是兄弟节点来生成对应编码
进行调用本存储过程时需要注意的是需要传递节点的层次(或是叫节点的深度)
另外下一个版本(V2.0)将根据用户自定义每级长度来实现更灵活的自动编码技术。
CREATEprocedureprcIDAutoGen
@vSourceIDvarchar(30),
@IDepthint,
@iIsSubNodeint,
@Tablevarchar(20),
@vIncrementvarchar(30)output
as
begin
declare@iLenint
declare@vTempIDvarchar(30)
declare@SQLStringnvarchar(500)
if@iIsSubNode=1
begin
set@IDepth=@IDepth+1
set@iLen=@IDepth*3
set@SQLString=N'selectvIDfrom'+@Table+'wherevID='''+ltrim(rtrim(@vSourceID))+''''
exec(@SQLString)
if@@rowcount>0
begin
select@vSourceIDasvIDinto#t
set@SQLString=N'insert#tselectvIDfrom'+@Table+'wherevParentIDin(selectvIDfrom#t) andvIDnotin(selectvIDfrom#t)andIDepth=@IDepth'
execsp_executesql@SQLString,N'@IDepthint',@IDepth
if@@rowcount>0
begin
set@SQLString=N'select @vTempID=isnull(max(vID),''0'')from#t'
execsp_executesql@SQLString,N'@vTempIDvarchar(30)output',@vTempID output
set@SQLString='select@vIncrement=right(''000''+cast((cast(substring(@vTempID,1,@iLen)asdecimal(30,0))+1)asvarchar),@iLen)'
execsp_executesql@SQLString,N'@vIncrementvarchar(30)output,@vTempIDvarchar(30),@iLenint',@vIncrementout,@vTempID,@iLen
end
else
begin
select @vIncrement=ltrim(rtrim(@vSourceID))+'001'
end
end
else
begin
select@vIncrement='001'
end
end
else
begin
set@iLen=len(ltrim(rtrim(@vSourceID)))
set@SQLString=N'selectvIDfrom'+@Table+'wherevID='''+ltrim(rtrim(@vSourceID))+''''
exec(@SQLString)
if@@rowcount>0
begin
set@SQLString=N'select @vTempID=isnull(max(vID),''0'')from'+@Table+'wherevIDin(selectvIDfrom'+@Table+'whereIDepth=@IDepth)'
execsp_executesql@SQLString,N'@vTempIDvarchar(30)output,@IDepthint',@vTempID output,@IDepth
set@SQLString='select@vIncrement=right(''000''+cast((cast(substring(@vTempID,1,@iLen)asdecimal(30,0))+1)asvarchar),@iLen)'
execsp_executesql@SQLString,N'@vIncrementvarchar(30)output,@vTempIDvarchar(30),@iLenint',@vIncrementout,@vTempID,@iLen
end
else
begin
select@vIncrement='001'
end
end
end
用户创建基础档案时可以按以下类似表格式创建:
createtableCustomerClass(
vID varchar(30)constraintpkCustomerClassprimarykey,1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- ERP基础档案管理模块中实现多级分类档案ID号自动编码技术(V1.0)
- ERP基础档案管理模块中实现多级分类档案ID号自动编码技术(V1.0)
- ERP基础档案管理模块中实现多级分类档案级联删除技术
- 基础档案 模块功能分析
- linux中装置档案管理
- 档案
- 档案
- 档案
- 编码档案描述EAD
- 档案目录管理--chmod
- 档案管理培训班
- 实验室档案管理
- Linux硬盘档案管理
- 档案与目录管理
- 管理自动工作量资料档案库(AWR)
- Linux基础学习-档案与目录管理1
- 东营市水文局档案管理实现电子化
- 东营市水文局档案管理实现电子化
- 如何查询其他内的表(IN子句实例)?
- 注册表
- 如何判断是否以独占方式打开当前?
- Ubuntu 8.04 LTS (Hardy Heron) DVD 下载
- 一个碎片整理程序的实现
- ERP基础档案管理模块中实现多级分类档案ID号自动编码技术(V1.0)
- 什么是COM组件
- 爱需要一生去领悟~!
- VC编译选项
- 得到对象脚本
- 允许单一实例运行的方法
- Groovy探索之invokeMethod方法
- 如何修复状态
- 浮点数取小数点后几位并对小数四舍五入