2
I have a precedent that I receive some data and these may come empty up there all right, but when the field is Enum and I try to set as null gives data truncated error for column even the field can receive null.
Example:
CREATE DEFINER=`root`@`localhost` PROCEDURE `fichacadastral_u`(
p_id_efetivo int(11) ,
p_origem_cert_reservista enum('Aeronáutica','Exército','Marinha')
)
BEGIN
update _rh.efetivo
set
origem_cert_reservista = if(p_origem_cert_reservista <> '', p_origem_cert_reservista, null)
where id_efetivo = p_id_efetivo;
select 'Cadastro efetuado com sucesso.' as msg, 0 as erro;
END
if I do a simple query type
update _rh.efetivo set origem_cert_reservista = null where id_efetivo = 4;
cool.
could help me?
I appreciate your help but this way when comes empty or zero gives truncate date error I found a solution and I will put the answer here
– opeta
Understood then it is much simpler, just do the check using if, ifnull etc.
– Mauro Rocha