Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TRIGGER verificarEmail
- ON cliente
- INSTEAD OF INSERT
- AS
- BEGIN
- declare @email CHAR(50);
- declare @codPostal CHAR(10)
- SELECT @email=i.email, @codPostal=i.codPostal FROM inserted i;
- IF NOT EXISTS (SELECT * FROM morada where codPostal = @codPostal)
- BEGIN
- INSERT INTO morada (codPostal, rua, cidade) VALUES (@codPostal, 'rua', 'morada')
- END
- INSERT INTO clientes (nome, telemovel, nif, codPostal, email, dataNascimento, sexo) VALUES (i.nome, i.telemovel, i.nif, i.codPostal, i.email, i.dataNascimento, i.sexo)
- IF @email NOT LIKE '%_@__%.__%'
- BEGIN
- Print 'Email inválido';
- ROLLBACK TRANSACTION
- END
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement