I cannot add values with Procedure in Mysql

Asked

Viewed 34 times

0

I’m doing a job with Mysql database and I’m having difficulties in Procedure maid:

DELIMITER $$
drop Procedure if exists cad_cat$$
CREATE PROCEDURE cad_cat(pnomeCat varchar(60))
BEGIN
INSERT INTO Categorias VALUES(pnomeCat);
END$$
DELIMITER ;

I don’t understand this mistake, can anyone explain to me?

call cad_cat('frutas');

Error Code: 1136. Column Count doesn’t match value Count at Row 1

  • Looks like your table Categorias has more than one column and you are trying to enter only one value. The error basically says that it does not match the column quantities of the table with the amount of values you entered.

  • 1

    It has two id and name fields, but the id I left as auto increment.

  • create table Categories( id_category int Primary key auto_increment not null, name varchar(60) not null)engine=Innodb charset=utf8;

  • 1

    Without specifying that you just want to enter the name, you need to specify that the id value will be the default. Or inform that it will only be the column nome which will be specified.

  • Thanks, I managed to fix the mistake :)

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.