I
I
Ivan Melnikov2018-03-28 14:47:49
MySQL
Ivan Melnikov, 2018-03-28 14:47:49

An error occurs when trying to write the second row to the table. How to fix?

MySQL 5.7 has a stored function that writes to the database:

CREATE function `insert_material` (_guid char(36), _name varchar(255)) returns int
BEGIN
declare b_guid binary(16);
set b_guid = unhex(replace(_guid, '-', ''));
insert into Material(guid, name) value(b_guid, _name);
return LAST_INSERT_ID();
END

The problem is that only one record can be made to the table. When trying to make a second entry, an error occurs:
5abb8097ca7c1317560132.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2018-03-28
@usdglander

...
insert ignore into Material(guid, name) value(b_guid, _name);
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question