MySql cross-database stored procedure operation NOTE _ MySQL

Source: Internet
Author: User
MySql cross-database stored procedure operation note 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 <20 do

Set tsid = '';

Select Province, sm_len, data_coding, province, src_addr, province, service_type, sm_content, link_id, region, 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 values (values, sm_len, data_coding, to_sp_id, src_addr, values, service_type, sm_content, link_id, values, 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

Author: Vionsam

BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.