daily pastebin goal
17%
SHARE
TWEET

Untitled

xickoh Jun 14th, 2018 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TRIGGER verificarEmail
  2. ON cliente
  3. INSTEAD OF INSERT
  4. AS
  5. BEGIN
  6.     declare @email CHAR(50);
  7.     declare @codPostal CHAR(10)
  8.     SELECT @email=i.email, @codPostal=i.codPostal FROM inserted i;
  9.  
  10.  
  11.  
  12. IF NOT EXISTS (SELECT * FROM morada where codPostal = @codPostal)
  13. BEGIN
  14.     INSERT INTO morada (codPostal, rua, cidade) VALUES (@codPostal, 'rua', 'morada')
  15. END
  16.  
  17. 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)
  18.  
  19.     IF @email NOT LIKE '%_@__%.__%'
  20.     BEGIN
  21.             Print 'Email inválido';
  22.             ROLLBACK TRANSACTION
  23.     END
  24.  
  25.  
  26. END
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top