Maison > base de données > tutoriel mysql > MySql跨库存储过程操作小记_MySQL

MySql跨库存储过程操作小记_MySQL

WBOY
Libérer: 2016-06-01 13:44:40
original
1560 Les gens l'ont consulté

bitsCN.com

 

BEGIN

    DECLARE deliverstatus,smlen,datacoding,total int;

    DECLARE tsid,srcaddr,destaddr,servicetype,smcontent,linkid,sequenceno,recvtime,state,resulttime,extcode,applicationid varchar(50) ;

 

    set total = 0;

   

while total

    set tsid='';

    select deliver_status,sm_len,data_coding,to_sp_id,src_addr,dest_addr,service_type,sm_content,link_id,sequence_no,recv_time,state,result_time,extcode_,applicationid_  into  deliverstatus,smlen,datacoding,tsid,srcaddr,destaddr,servicetype,smcontent,linkid,sequenceno,recvtime,state,resulttime,extcode,applicationid

       from tlc_to_sp where applicationid_ = 'sms_db' limit 0,1;

    if tsid '' then

        if resulttime ''  and recvtime  '' then

        insert into kingterdb.sms_inbox(MASSMSID,SOURCEADDR,RECEIVETIME,MESSAGECONTENT,REQUESTTIME,extcode,applicationid) values(tsid,srcaddr,resulttime,smcontent,recvtime,extcode,applicationid);

        elseif resulttime = '' then

        insert into kingterdb.sms_inbox(MASSMSID,SOURCEADDR,RECEIVETIME,MESSAGECONTENT,REQUESTTIME,extcode,applicationid) values(tsid,srcaddr,now(),smcontent,recvtime,extcode,applicationid);

        elseif recvtime = '' then

        insert into kingterdb.sms_inbox(MASSMSID,SOURCEADDR,RECEIVETIME,MESSAGECONTENT,REQUESTTIME,extcode,applicationid) values(tsid,srcaddr,resulttime,smcontent,now(),extcode,applicationid);

        else

        insert into kingterdb.sms_inbox(MASSMSID,SOURCEADDR,RECEIVETIME,MESSAGECONTENT,REQUESTTIME,extcode,applicationid) values(tsid,srcaddr,now(),smcontent,now(),extcode,applicationid);

        end if;    

        insert into tlc_to_sp_his(deliver_status,sm_len,data_coding,to_sp_id,src_addr,dest_addr,service_type,sm_content,link_id,sequence_no,recv_time,state,result_time,extcode_,applicationid_) values(deliverstatus,smlen,datacoding,tsid,srcaddr,destaddr,servicetype,smcontent,linkid,sequenceno,recvtime,state,resulttime,extcode,applicationid);

    end if;

   

    delete from tlc_to_sp where to_sp_id in(select to_sp_id from tlc_to_sp_his where applicationid_ = 'sms_db');

 

    set total = total + 1;

end while;

END

 

作者:Vionsam

bitsCN.com
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal