4
I’m a beginner in procedures.
I am trying to insert data into a table using a procedure, where I get the table name, the column names and the values of these.
How to receive the types of data I want, such as a table or a column?
I’m thinking right about using a procedure for this?
Here’s an excerpt from the code:
CREATE PROCEDURE `inserirUsuario`(tableName varchar(45),column5 varchar
(45),dado5 varchar(45),column6 varchar (45),dado6 varchar(45),column1
varchar (45),dado1 varchar(45),column2 varchar (45),dado2 varchar(45),
column3 varchar (45),dado3 varchar(45),column4 varchar (45),dado4
varchar(45) )
BEGIN
DECLARE id int;
insert into endereco(column1, column2, column3, column4) values
(dado1,dado2,dado3,dado4);
Sqlserver, mysql ?
– Thiago Loureiro
The information comes from where? From an application? From SQL itself? If the goal is just to insert data into a table, I don’t see why to use a
Stored Procedure
.– João Martins
There is a simpler way to use parameter with table value. See https://docs.microsoft.com/pt-br/sql/relational-databases/tables/use-table-valued-parameters-database-engine
– José Diz