DELIMITER $$
CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
PROCEDURE `proc_recordByRecordSelect`(whereStr VARCHAR(2000),
tableName VARCHAR(200),
tmpTableName VARCHAR(200))
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT “string”*/
BEGIN
SET @sql := CONCAT(
“insert into “, tmpTableName,
“select ……………”
);
PREPARE sql_text FROM @sql;
EXECUTE sql_text;
DEALLOCATE PREPARE sql_text;
END$$
DELIMITER ;
创建了一个插入多条数据的存储过程,各位高手本人想要返回插入了多少条的结果怎么搞阿?
CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
PROCEDURE `proc_recordByRecordSelect`(whereStr VARCHAR(2000),
tableName VARCHAR(200),
tmpTableName VARCHAR(200))
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT “string”*/
BEGIN
SET @sql := CONCAT(
“insert into “, tmpTableName,
“select ……………”
);
PREPARE sql_text FROM @sql;
EXECUTE sql_text;
DEALLOCATE PREPARE sql_text;
END$$
DELIMITER ;
创建了一个插入多条数据的存储过程,各位高手本人想要返回插入了多少条的结果怎么搞阿?
解决方案
40
EXECUTE sql_text;之后添加下面语句,
SELECT ROW_COUNT()
将数量存入变量,先声明变量
DECLARE V_RECODRS INT;
SELECT ROW_COUNT() INTO V_RECODRS;
SELECT ROW_COUNT()
将数量存入变量,先声明变量
DECLARE V_RECODRS INT;
SELECT ROW_COUNT() INTO V_RECODRS;