1
I would like it if, by inserting it in the Customers table in the bank 1, it were inserted in the Customers table in the bank 2, but only if there is no more. Currently my code is like this:
DELIMITER $$
CREATE TRIGGER trIntegracaoBancos AFTER INSERT
ON banco1.clientes FOR EACH ROW
BEGIN
IF NOT EXISTS (SELECT id FROM banco2.Clientes) THEN
INSERT INTO banco2.Clientes (id, nome, dat_nascimento, cpf, rg, endereco, numero, bairro, cidade, estado, cep)
SELECT id, nome, dat_nascimento, cpf, rg, endereco, numero, bairro, cidade, estado, cep;
END IF;
END;
$$
The if check should check if there is no.
" INSERT INTO products (name, category, description) VALUES ('Black Join', 'Electronics', 'Lorem Ipsum); " only inserts if it does not exist by default if it returns an error.
– Luciano Alves
Do not edit your question with an answer. Please read the [Tour] and [Help] to better understand the site.
– Bacco
Bacco my later comment was not a comment, but a solution. I should read the content before making any decision.
– Weslley Fillipe