Click here to Skip to main content
15,896,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want insert the data in table in mysql database but problem is that


i am using the store procedure for insert data


i want to assign the table name like

SQL
DROP PROCEDURE IF EXISTS `sp_insert_data` $$
CREATE DEFINER=`root`@`%` PROCEDURE `sp_insert_data`(
in temp_table_name varchar(40))
 

how to write insert statement

like 
insert into temp_table_name values();


becauese i have 450 tables and i want whatever string in temp_table_name  i want to insert in that table...

pls fast reply
Posted

1 solution

This is a really insane idea. If you want to generate SQL on the fly to this degree, there's no point using stored procs. In SQL Server, you can build a SQL string and call EXEC on it, if MySQL allows this, it's the only way this would be possible. Unless all your tables have the same number of variables, you are going to have issues there, plus it means you're not specifying what columns you are inserting in, which is also a bad idea.

This is a nightmare, don't do it. If you have 450 tables, you have a big project, which deserves far better code than this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900