【統計商戶24個月連續流水總月數儲存過程】

leonarding發表於2016-01-22
【統計商戶24個月連續流水總月數儲存過程】
刪除儲存過程
SQL> drop procedure checklen;
 
Procedure dropped
建立儲存過程
SQL> CREATE OR REPLACE PROCEDURE checklen(val in varchar2,resultval out number) as
    maxlen number;
    nowlen number;
    begin
    maxlen := 0;
    nowlen := 0;
    
    for i in 1..24 loop
      if substr(val,i,1)='0' then
       nowlen := 0;
     else
       nowlen := nowlen + 1;
       if nowlen>maxlen then
         maxlen := nowlen;
       end if;
     end if;
   end loop;
   resultval := maxlen;
   END;
/
開啟螢幕輸出
set serveroutput on;
測試儲存過程
declare
resultval number;
begin
checklen('111000000000000000011110',resultval);
dbms_output.put_line(resultval);
end;
/


4
 
PL/SQL procedure successfully completed

劉盛 Leonarding
2016.1.14
北京&winter
分享技術~成就夢想
Blog:www.leonarding.com

如果喜歡我的文章就請掃下面二維碼吧!關注微訊號:leonarding_public
在這裡你能得到技術、實事、熱點訊息等新興事物的思考和觀點,別的地方可能沒有的東西。我將為大家提供最新技術與資訊動態,傳遞正能量。
【統計商戶24個月連續流水總月數儲存過程】

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26686207/viewspace-1980926/,如需轉載,請註明出處,否則將追究法律責任。

相關文章