作者热门文章
- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章Oracle生成单据编号存储过程的实例代码由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
Oracle生成单据编号存储过程,在做订单类似的系统都可能会存在订单编号不重复,或是流水号按日,按年,按月进行重新编号.
可以参考以下存储过程 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
CREATE
OR
REPLACE
procedure
Pro_GetBillNO(TypeTable
in
varchar2,cur_mycursor
out
sys_refcursor)
as
DReceiptCode varchar2(40);
DReceiptName varchar2(50);
DPrefix1 varchar2(50);
DISO varchar2(50);
DIsAutoCreate varchar2(20);
DPrefix2 varchar2(20);
DPrefix3 varchar2(20);
DDateValue
date
;
DNO number;
DLength number;
DResetType number;
DSeparator varchar2(20);
DReturnValue varchar2(50);
strSql varchar2(1000);
begin
DReturnValue:=
''
;
select
"ReceiptCode"
,
"ReceiptName"
,
"Prefix1"
,
"ISO"
,
"IsAutoCreate"
,
"Prefix2"
,
"Prefix3"
,
"DateValue"
,
"NO"
,
"Length"
,
"ResetType"
,
"Separator"
into
DReceiptCode,DReceiptName,DPrefix1,DISO,DIsAutoCreate,DPrefix2,DPrefix3,DDateValue,DNO,DLength,DResetType,DSeparator
from
"SysReceiptConfig"
where
"ReceiptCode"
=TypeTable;
if to_number(DResetType)>0
then
if DIsAutoCreate=1
THEN
if DResetType=1
then
--按年份
if to_number(to_char(sysdate,
'yyyy'
)) <>to_number(to_char(DDateValue,
'yyyy'
))
then
update
"SysReceiptConfig"
set
"NO"
=1,
"DateValue"
=to_date(sysdate)
where
"ReceiptCode"
=TypeTable;
else
update
"SysReceiptConfig"
set
"NO"
=
"NO"
+1
where
"ReceiptCode"
=TypeTable;
end
if;
--年份
end
if;
--DResetType=1
if DResetType=2
then
--按月份
if to_number(to_char(sysdate,
'MM'
)) <>to_number(to_char(DDateValue,
'MM'
))
then
update
"SysReceiptConfig"
set
"NO"
=1,
"DateValue"
=to_date(sysdate)
where
"ReceiptCode"
=TypeTable;
else
update
"SysReceiptConfig"
set
"NO"
=
"NO"
+1
where
"ReceiptCode"
=TypeTable;
end
if;
--月份
end
if;
--DResetType=2
if DResetType=3
then
--按日
if to_number(to_char(sysdate,
'dd'
)) <>to_number(to_char(DDateValue,
'dd'
))
then
update
"SysReceiptConfig"
set
"NO"
=1,
"DateValue"
=to_date(sysdate)
where
"ReceiptCode"
=TypeTable;
else
update
"SysReceiptConfig"
set
"NO"
=
"NO"
+1
where
"ReceiptCode"
=TypeTable;
end
if;
--月份
end
if;
--DResetType=3
else
update
"SysReceiptConfig"
set
"NO"
=
"NO"
+1
where
"ReceiptCode"
=TypeTable;
end
if;
--DResetType
end
if;
strSql:=
' select * from "SysReceiptConfig" where 1=1 '
;
strSql:=strSql ||
' and "ReceiptCode"='
''
||TypeTable||
''
''
;
open
cur_mycursor
for
strSql;
end
;
|
以上所述是小编给大家介绍的Oracle生成单据编号存储过程的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我网站的支持! 。
原文链接:http://www.2cto.com/database/201704/633244.html 。
最后此篇关于Oracle生成单据编号存储过程的实例代码的文章就讲到这里了,如果你想了解更多关于Oracle生成单据编号存储过程的实例代码的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我是一名优秀的程序员,十分优秀!