mysqlgoto_mysql的goto语句⽤法?procedure中goto语句如何⽤?关于goto在mysql的⼿册中没有写,
到底⽀持否?
下⾯的语句goto不知道那⾥不对?
如果不⽤goto其他有可以替代的吗?
SET SQLStr = 'CREATE TEMPORARY TABLE tmpPosAnalyse AS';
SET SQLStr = CONCAT(SQLStr, ' SELECT Pos_code PosCode,');
SET SQLStr = CONCAT(SQLStr, ' SUM(Trade_money) TotalMoney,');
SET SQLStr = CONCAT(SQLStr, ' Pos_date TradeDate,');
SET SQLStr = CONCAT(SQLStr, ' FROM Trade_logs ');
IF PosCode <> '' THEN
SET TmpStr = CONCAT(' WHERE Pos_code = ', PosCode);
exists的用法
SET TmpStr = CONCAT(TmpStr, TmpAndDate);
SET TmpStr = CONCAT(TmpStr, TmpTradeType);
goto label_exec;
END IF;
IF MerchantCode <> '' THEN
SET TmpStr = CONCAT(' WHERE merchant_code = ', MerchantCode);
ELSE
SET TmpStr = CONCAT(TmpStr, ' WHERE Merchant_Code IN');
SET TmpStr = CONCAT(TmpStr, ' (SELECT BizCode FROM  BizInfo WHERE BranchCode = ');
SET TmpStr = CONCAT(TmpStr, BranchCode);
SET TmpStr = CONCAT(TmpStr, ') ');
END IF;
label:label_exec:
DROP TEMPORARY TABLE IF EXISTS tmpPosAnalyse;
SET @SQLStr = CONCAT(SQLStr, ' GROUP BY Pos_code;');
PREPARE stmtPos FROM @SQLStr;
EXECUTE stmtPos;
DEALLOCATE PREPARE stmtPos;
SELECT * FROM tmpPosAnalyse;
作者: cnredcat
发布时间: 2006-11-01

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。