Oracle生成單據(jù)編號(hào)存儲(chǔ)過程,在做訂單類似的系統(tǒng)都可能會(huì)存在訂單編號(hào)不重復(fù),或是流水號(hào)按日,按年,按月進(jìn)行重新編號(hào)。
筠連網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,筠連網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為筠連千余家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的筠連做網(wǎng)站的公司定做!
可以參考以下存儲(chǔ)過程
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生成單據(jù)編號(hào)存儲(chǔ)過程的實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!