DELIMITER $$
CREATE PROCEDURE `Insert1`(IN NAME VARCHAR(100),IN valuees VARCHAR(100))
BEGIN
SET @r = CONCAT('Insert into', NAME,'(name)','VALUES',valuees);
PREPARE smpt FROM @r;
EXECUTE smpt;
DEALLOCATE PREPARE smpt;
END$$
DELIMITER ;
it is successfully compiling…
but when i execute gives me problem…
**CALL Insert1('rishi','duyuu')**
Error Code : 1064
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 ‘VALUESduyuu’ at line 1
There are multiple problems, first see what query has the
CONCATfunction produced. You will notice that it’s not a valid query –'Insert intorishi(name)VALUESduyuu'. Next, see the documentation onPREPARE/EXECUTEand use a placeholder for the value. The string would need to be put into quotes and escaped if you want to produce a raw query string. So try something like this:Btw, instead of asking a number of small questions here, maybe you should ask a more high level question, explain what you have tried, what failed, etc. It’s easier to help you with high level issues, but if you are doing something the wrong way and ask small technical questions how to fix it so that it works the wrong way, it won’t help you much.