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 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,srca