Error in MySQL procedure

0

People are doing this procedure:

CREATE DEFINER='root'@'localhost' PROCEDURE 'adicionarPessoaTelefone'
(IN     cpf VARCHAR(14) ,
IN nome VARCHAR(100),
IN rg VARCHAR(9),
IN data_nasc DATE,
IN end_rua VARCHAR(200),
IN end_bairro VARCHAR(25),
IN end_cidade VARCHAR(20),
IN end_estado VARCHAR(2),
IN email VARCHAR(100),
IN telefone1 varchar(12),
IN telefone2 varchar(12) )

BEGIN

    insert into pessoas values (cpf, nome, rg, data_nasc, end_rua, end_bairro, end_cidade,end_estado, email);
    insert into telefone_pessoas (Pessoas_CPF, Telefone) values (cpf, telefone1);

        if (telefone2 <> null) then
            insert into telefone_pessoas (Pessoas_CPF, Telefone) values (cpf, telefone2);
        end if;
END

The idea is to only register the second phone if it is different from null, but it is not registering.

    
asked by anonymous 17.05.2018 / 08:11

0 answers