help,mysql存储过程问题SQL codeCREATE DEFINER`root`@`localhost` PROCEDURE `test`(IN id BIGINT(20),I
help,mysql存储过程问题
SQL code
CREATE DEFINER=`root`@`localhost` PROCEDURE `test`( IN id BIGINT(20), IN newSize int(20), IN newConut int(20), IN newPrice FLOAT(8,4) )BEGIN DECLARE Size INT; DECLARE Count INT; DECLARE Price FLOAT;set @q1=CONCAT('select size,count,price INTO Size,Count,Price from ',id,'_testschema.testtable where datetime BETWEEN "',CURDATE(),' 00:00:00" and "',CURDATE(),' 23:59:59"');prepare st1 from @q1;deallocate prepare st1;........end[code=SQL]
[解决办法] 你没有SELECT 变量名,怎么会有结果 SET @q1=CONCAT('select size,count,price INTO @Size,@Count,@Price from ',id,'_testschema.testtable where datetime BETWEEN \'',CURDATE(),' 00:00:00 \' and \'',CURDATE(),' 23:59:59\''); PREPARE st1 FROM @q1; EXECUTE st1; SET @q2=CONCAT('UPDATE ',accountid,'_account.T_UsedRecordForEveryDay SET space_size=',@Size,',machine_count=',@Conut,',day_price=',@Price ,'where datetime BETWEEN "',CURDATE(),' 00:00:00" and "',CURDATE(),' 23:59:59"'); PREPARE st2 FROM @q2; EXECUTE st2 ; DEALLOCATE PREPARE st2; deallocate prepare st1; [解决办法] set @q1=CONCAT('select size,count,price INTO @Size,@Count,@Price from ',id,'_testschema.testtable where datetime BETWEEN "',CURDATE(),' 00:00:00" and "',CURDATE(),' 23:59:59"'); prepare st1 from @q1; deallocate prepare st1; set Size=@size; .. [解决办法]