标签:
CREATE OR REPLACE PROCEDURE Campaignprize_hash( ServerNum number, RETVAL OUT VARCHAR2) IS RNum number(6); SIndex number(2); hashcodd VARCHAR2(8); flag number(2); begin SIndex:=0; DECLARE CURSOR c1 IS select campaignprizeid,CAMPAIGNID,PRIZETYPEID from mkt_campaignprize where issend=0 order by campaignprizeid asc; BEGIN FOR r1 IN c1 LOOP if SIndex=ServerNum then SIndex:=0; end if; select count(1) into flag from mkt_RangeNum t where t.serverindex=SIndex and t.campaignid=r1.CAMPAIGNID and t.prizetypeid=r1.PRIZETYPEID and rownum<=1; if flag>0 then select t.RangeNum into RNum from mkt_RangeNum t where t.serverindex=SIndex and t.campaignid=r1.CAMPAIGNID and t.prizetypeid=r1.PRIZETYPEID; RNum:=RNum+1; update mkt_RangeNum t set t.RangeNum=RNum where t.serverindex=SIndex and t.campaignid=r1.campaignid and t.prizetypeid=r1.prizetypeid; else RNum:=0; insert into mkt_RangeNum values(SIndex,r1.CAMPAIGNID,r1.PRIZETYPEID,RNum); end if; hashcodd:=lpad(SIndex,2,‘0‘)||lpad(RNum,6,‘0‘); update mkt_campaignprize mc set mc.hashcode=hashcodd where mc.campaignprizeid=r1.campaignprizeid; SIndex:=SIndex+1; END LOOP; END; COMMIT; RETVAL := ‘1‘; Exception When others then RETVAL :=‘E‘||SUBSTR(SQLERRM, 1, 600); end Campaignprize_hash;
create global temporary table mkt_RangeNum (ServerIndex number(2), CampaignID number(19), PrizeTypeID number(19), RangeNum number(6)) on Commit delete Rows
标签:
原文地址:http://www.cnblogs.com/linbl/p/4661852.html