CREATE PROCEDURE `addTicket`(in vipsql VARCHAR(255),in ordersql VARCHAR(255),in detailkey varchar(255),in detailsql VARCHAR(255)) comment '掛單(售藥窗口)'
公司主營業(yè)務(wù):成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、移動(dòng)網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。成都創(chuàng)新互聯(lián)公司是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來驚喜。成都創(chuàng)新互聯(lián)公司推出鄠邑免費(fèi)做網(wǎng)站回饋大家。
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='插入到【會(huì)員表】失敗';
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
本文名稱:存儲(chǔ)過程定義語法
網(wǎng)址分享:http://m.newbst.com/article24/jescje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、搜索引擎優(yōu)化、網(wǎng)站導(dǎo)航、做網(wǎng)站、面包屑導(dǎo)航、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)