大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
CREATE PROCEDURE `addTicket`(in vipsql VARCHAR(255),in ordersql VARCHAR(255),in detailkey varchar(255),in detailsql VARCHAR(255)) comment '挂单(售药窗口)'
公司主营业务:成都网站建设、网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联公司推出鄠邑免费做网站回馈大家。
BEGIN
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION ,NOT FOUND
rollback;
start transaction;
set @vid=@oid='';
set @outstr='';
set @errcode=200;
set @errmsg='成功';
if vipsql=0 then
set @tem=vipsql;
prepare tem from @tem;
execute tem;
set @rows=row_count();
if @rows<=0 then
set @errcode=501;
set @errmsg='插入到【会员表】失败';
rollback;
end if;
set @vid=LAST_INSERT_ID();
else
set @vid=vipsql;
end if;
select order_outpatient_num into @cnum from `order` order by order_outpatient_num desc limit 1;
if locate(curdate()+0,@cnum)=0||@cnum='' then
set @cnum=concat(curdate()+0,'00000001');
else
set @cnum=@cnum+1;
end if;
set ordersql=concat(ordersql,"'",@vid,"','",@cnum,"')");
set @ordersql=ordersql;
prepare temp from @ordersql;
execute temp;
set @rows=row_count();
if @rows<=0 then
set @errcode=502;
set @errmsg='插入到【订单表】失败';
rollback;
end if;
set @oid=LAST_INSERT_ID();
set @num=(length(detailsql)-length(replace(detailsql,'*#*','')))/3+1;
set @i=1;
while @i<=@num do
if @i=1 then
set @strsql=substring_index(detailsql,'*#*',@i);
else
set @strsql=substring_index(detailsql,'*#*',@i);
set @strsql=substring_index(@strsql,'*#*',-1);
end if;
set @outstr=concat(@outstr,@strsql,"'",@cnum,"','",@oid,"'),");
set @i=@i+1;
end while;
set @outstr=concat(detailkey,@outstr);
set @outstr=left(@outstr,char_length(@outstr)-1);
prepare temp0 from @outstr;
execute temp0;
set @rows=row_count();
if @rows<=0 then
set @errcode=503;
set @errmsg='插入到【订单详情表】失败';
rollback;
end if;
commit;
select @errcode as errcode,@errmsg as errmsg;
END