存储过程定义语法


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
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
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
if @i=1 then set @strsql=substring_index(detailsql,’*#*’,@i); else set @strsql=substring_index(detailsql,’*#*’,@i); set @strsql=sub开发云主机域名string_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
set @errcode=503; set @errmsg=’插入到【订单详情表】失败’; rollback; end if; commit; select @errcode as errcode,@errmsg as errmsg;END

相关推荐: MySQL可视化工具推荐

为方便使用MySQL,本文列举出几个MySQL的可视化工具,各位可各取所需! 1、MyDB Studio 该工具包含MySQL服务管理的完整工具集,功能比较强大,但是是收费的,且在选择表格数据时会加载表格所有数据,速开发云主机域名度方面有影响。 2、DB to…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

Like (0)
Donate 微信扫一扫 微信扫一扫
Previous 06/04 21:39
Next 06/04 21:39

相关推荐