-2
Running procudure below Mysql Workbench shows error:
"Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, toggle the option in Preferences -> SQL Editor and Reconnect."
However, the only UPDATE
of the past uses the primary key of the table.
DELIMITER $$
CREATE PROCEDURE Editar_Produtos(
IN Id_Pro INT,
IN Cod_Int VARCHAR (21),
IN Nom_Pro VARCHAR (55),
IN Id_Cat INT,
IN Id_Cla INT,
IN Id_Sub INT,
IN Id_Mil INT,
IN Id_Med INT,
IN Id_Mar INT,
IN Vlr_Cust DECIMAL (9,2),
IN Vlr_Vend DECIMAL (9,2),
IN Id_Un INT,
IN Id_Tpd INT
)
BEGIN
UPDATE ktsproduto
SET COD_INT = Cod_Int,
NOM_PRO = Nom_Pro,
ID_CAT = Id_Cat,
ID_CLA = Id_Cla,
ID_SUB = Id_Sub,
ID_MIL = Id_Mil,
ID_MED = Id_Med,
ID_MAR = Id_Mar,
VLR_CUST = Vlr_Cust,
VLR_VEND = Vlr_Vend,
ID_UN = Id_Un,
ID_TPD = Id_Tpd
WHERE ID_PRO = Id_Pro;
END $$
DELIMITER ;
CALL Editar_Produtos(
'417',"KTSKTSKTS","KENNEDY TEIXIERA",'1','1','1','1','1','1','250.99','500.99','1','1');
I do not understand why the mistake, since I am using the clause WHERE
with the primary key of the table.
If possible, I don’t want to rotate SET SQL_SAFE_UPDATES=0;
, for safety reasons.
Restart mysql server and test.
– thiaguerd
ID_PRO is a key ?
– Rovann Linhalis
Yes, it’s a key.
– Kennedy Teixeira
I was able to solve the problem, after doing many tests, realize that when removing the underline " _ " of all variables worked perfectly, ie Id_pro, Id_cat were like this Idpro, Idcat configured from this outside and gave right. I thank the other people who cared about my question. Thank you.
– Kennedy Teixeira
I could not understand why the question was closed. It seems to me a good question and with the problem well exposed.
– tvdias
@Kennedyteixeira, although I have "turned the problem around," I think I can explain his reason in my answer. Came to check if it works properly?
– tvdias
@tvdias thank you very much, your solution proposal worked, now I can better organize my code, this topic is very useful, should not be closed.
– Kennedy Teixeira
As for the closing, let’s see if it’s reviewed. :)
– tvdias