I have some sql statements that I am preparing in code which I pass to a stored procedure to execute via the prepare statement but I keep getting an error, how can I get around this?
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';insert into tblA(b)values (200)' at line 1
Code:
create table tblA(a int auto_increment primary key, b int)
CREATE PROCEDURE `foobar`(IN sSQL varchar(1000))
NOT DETERMINISTIC
SQL SECURITY DEFINER
COMMENT ''
begin
SET @sSQL = sSQL;
PREPARE stmt FROM @sSQL;
EXECUTE stmt;
end;
call foobar("insert into tblA(b)values(100);insert into tblA(b)values (200);");
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';insert into tblA(b)values (200)' at line 1