SET @v1 = '';
SET @v2 = '';
SET @Query = CONCAT('SELECT sum(colName1), sum(colName2) INTO @v1, @v2 FROM tableName WHERE id=1 ');
PREPARE stmt FROM @Query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @Query = CONCAT('SELECT id, name,',@v1,' as value1, ',@v2,' as value2 FROM tableName WHERE id=1 ');
PREPARE stmt FROM @Query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
在读取值时抛出异常 - 列'value1'不属于表格。
如何获取@ v1和@ v2的值。
请帮帮我。
答案 0 :(得分:0)
@ v2具有null 值,表示存储过程导致错误的原因。