Error inserting Data in Mysql

0

I have this query to insert a data into the database:

INSERT INTO 'bancoTeste'.'TabelaTeste' ('t_id','t_label', 't_parametro', 't_valor', 't_descricao', 't_valores_padrao', 't_tipo') 
VALUES ('NULL','Cargas', 'monitorar_carga','N', 'apresentar as cargas dos veículos do grupo de monitoramento','sim_ou_nao', 'combo');

mysql error

  

1 row (s) affected, 1 warning (s): 1366 Incorrect integer value: 'NULL'   for column 'sis00_id' at row 1

How to proceed?

    
asked by anonymous 29.11.2017 / 14:04

2 answers

4

Remove the quotation marks from 'NULL' , otherwise it will be a string incompatible with the value type of the column t_id of the table.

With 'NULL' (in quotation marks), you will insert the record into the table, according to the message:

  

1 row (s) affected

But it will generate the alert:

  

1 warning (s)

In the form below, the alert will not be generated:

INSERT INTO 'bancoTeste'.'TabelaTeste' ('t_id','t_label', 't_parametro', 't_valor', 't_descricao', 't_valores_padrao', 't_tipo') 
VALUES (NULL,'Cargas', 'monitorar_carga','N', 'apresentar as cargas dos veículos do grupo de monitoramento','sim_ou_nao', 'combo');

But if the column t_id is primary-key auto_increment , just omit it:

INSERT INTO 'bancoTeste'.'TabelaTeste' ('t_label', 't_parametro', 't_valor', 't_descricao', 't_valores_padrao', 't_tipo') 
VALUES ('Cargas', 'monitorar_carga','N', 'apresentar as cargas dos veículos do grupo de monitoramento','sim_ou_nao', 'combo');
    
29.11.2017 / 14:10
0

Just remove the t_id from sql. Is this field set to auto_increment in your database? If it is enough just remove it. The sql would look like this:

INSERT INTO 'bancoTeste'.'TabelaTeste' ('t_label', 't_parametro', 't_valor', 't_descricao', 't_valores_padrao', 't_tipo') VALUES ('Cargas', 'monitorar_carga','N', 'apresentar as cargas dos veículos do grupo de monitoramento','sim_ou_nao', 'combo');
    
29.11.2017 / 14:16