我是新来的存储过程我将三个字符串传递给过程(table_name,fields_name,values)以插入数据。
DELIMITER
CREATE PROCEDURE insert_into(IN table_name VARCHAR(255),IN fields_name VARCHAR(255),IN valuess VARCHAR(255),)
BEGIN
SET @sql = CONCAT('insert into ',table_name,'(',fields_name,')values (',valuess,')');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END
DELIMITER ;
获取错误
#1054 - Unknown column 'table_name' in 'field list'
答案 0 :(得分:0)
DELIMITER $$
--
-- Procedures
--
CREATE DEFINER=`root`@`localhost` PROCEDURE `insert_value` (IN `table_name` VARCHAR(1000), IN `fields_name` TEXT, IN `valuess` TEXT)
BEGIN
SET @sql = CONCAT('insert into ',table_name,'(',fields_name,')values (',valuess,')');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END$$
DELIMITER ;