Oracle生成單據(jù)編號(hào)存儲(chǔ)過程的實(shí)例代碼
Oracle生成單據(jù)編號(hào)存儲(chǔ)過程,在做訂單類似的系統(tǒng)都可能會(huì)存在訂單編號(hào)不重復(fù),或是流水號(hào)按日,按年,按月進(jìn)行重新編號(hào)。
可以參考以下存儲(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ì)大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- oracle 存儲(chǔ)過程、函數(shù)和觸發(fā)器用法實(shí)例詳解
- windows中oracle存儲(chǔ)過程加密的實(shí)例代碼
- Oracle帶輸入輸出參數(shù)存儲(chǔ)過程(包括sql分頁功能)
- oracle中print_table存儲(chǔ)過程實(shí)例介紹
- Mybatis調(diào)用Oracle存儲(chǔ)過程的方法圖文詳解
- 詳解Oracle調(diào)試存儲(chǔ)過程
- Oracle存儲(chǔ)過程和存儲(chǔ)函數(shù)創(chuàng)建方法(詳解)
- Oracle存儲(chǔ)過程及調(diào)用
- Oracle存儲(chǔ)過程、包、方法使用總結(jié)(推薦)
- Oracle數(shù)據(jù)庫創(chuàng)建存儲(chǔ)過程的示例詳解
相關(guān)文章
ORACLE數(shù)據(jù)庫對(duì)long類型字段進(jìn)行模糊匹配的解決思路
這篇文章主要介紹了ORACLE數(shù)據(jù)庫對(duì)long類型字段進(jìn)行模糊匹配的解決思路,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-04-04oracle 視圖權(quán)限 oracle 創(chuàng)建視圖權(quán)限不足
在scott用戶下創(chuàng)建視圖的時(shí)候,報(bào)錯(cuò):權(quán)限不足,遇到這個(gè)問題,我也是束手無策,于是網(wǎng)上搜集整理了一下,曬出來和大家分享,希望可以幫助你們2012-11-11Oracle導(dǎo)出文本文件的三種方法(spool,UTL_FILE,sqluldr2)
這篇文章主要介紹了Oracle導(dǎo)出文本文件的三種方法(spool,UTL_FILE,sqluldr2),需要的朋友可以參考下2023-05-05部署Oracle 12c企業(yè)版數(shù)據(jù)庫( 安裝及使用)
這篇文章主要介紹了部署Oracle 12c企業(yè)版數(shù)據(jù)庫( 安裝及使用),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11Oracle三種循環(huán)(For、While、Loop)實(shí)現(xiàn)九九乘法表
這篇文章主要為大家詳細(xì)介紹了Oracle三種循環(huán)For、While、Loop實(shí)現(xiàn)九九乘法表,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03Oracle配置dblink訪問PostgreSQL的操作方法
本文給大家介紹下Oracle配置dblink訪問PostgreSQL的操作方法,通過dblink訪問PostgreSQL的詳細(xì)過程,對(duì)Oracle?dblink訪問PostgreSQL相關(guān)知識(shí)感興趣的朋友一起看看吧2022-03-03