oracle存储过程插入自动编号,Oracle生成单据编号存储过程的实例代码

Oracle生成单据编号存储过程,在做订单类似的系统都可能会存在订单编号不重复,或是流水号按日,按年,按月进行重新编号。

可以参考以下存储过程

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生成单据编号存储过程的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程之家网站的支持!

总结

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值