Oracle生成单据编号存储过程的实例代码
作者:PariyPeng 时间:2024-01-23 19:10:19
Oracle生成单据编号存储过程,在做订单类似的系统都可能会存在订单编号不重复,或是流水号按日,按年,按月进行重新编号。
可以参考以下存储过程
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,单据编号,存储过程


猜你喜欢
python绘制雷达图实例讲解
2022-03-11 01:58:23

selenium WebDriverWait类等待机制的实现
2022-12-18 13:07:21
Python命令行参数解析模块getopt使用实例
2021-02-20 08:53:48
从IIS到SQL Server数据库安全
2008-12-24 15:58:00
SQL2000个人版 应用程序正常初始化失败0乘以C0000135失败
2024-01-27 05:09:39
Python3 虚拟开发环境搭建过程(图文详解)
2021-11-19 00:34:51

Div即父容器不根据内容自适应高度的解决方法
2010-04-23 18:19:00
sqlserver分页的两种写法分别介绍
2024-01-24 15:58:18
ASP函数验证带小数点数字格式
2010-01-02 20:41:00
关于 Flash Banner 设计的建议
2010-02-02 18:19:00
python使用xlrd和xlwt读写Excel文件的实例代码
2021-08-30 08:43:55
pandas数据分组和聚合操作方法
2023-09-07 05:15:44
SQL Server的复制功能
2024-01-16 19:40:27

Python之random库的常用函数有哪些
2022-10-04 03:01:13

vue之封装多个组件调用同一接口的案例
2024-04-09 10:47:32
不要忽略了颜色的可用性
2009-03-05 18:19:00

SQL Server数据库服务器高性能设置
2010-11-25 16:00:00
JavaScript简单实现的仿微博留言功能示例
2024-04-17 10:01:33

Python 合并拼接字符串的方法
2022-05-26 08:58:08
简单掌握Python的Collections模块中counter结构的用法
2023-05-17 00:20:13