Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. -- --------------------------------------------------------------------------------
  2. -- Routine DDL
  3. -- --------------------------------------------------------------------------------
  4. DELIMITER $$
  5.  
  6. CREATE DEFINER=`root`@`localhost` PROCEDURE `insertatbroperacion`(IN xFecha DATE, xidCatcuentas INT, xidCatlistas INT, xidCattemplates INT,
  7. xidCatusuarios INT, xEmail VARCHAR(45), xResultado VARCHAR(2), xIteracion INT, xAsunto VARCHAR(90))
  8. BEGIN
  9. DECLARE xIntUltimoRegistro INT;
  10. IF xIteracion = 0 THEN
  11. INSERT INTO tbroperacion (fecha, asunto, catcuentas_idCatcuentas, catlistas_idCatlistas, cattemplates_idCattemplates, catusuarios_idCatusuarios)
  12. VALUES (xFecha, xAsunto, xidCatcuentas, xidCatlistas, xidCattemplates, xidCatusuarios);
  13.  
  14. SET xIntUltimoRegistro = last_insert_id();
  15. ELSE
  16. SELECT idTbroperacion FROM tbroperacion
  17. WHERE fecha = xFecha AND catcuentas_idCatcuentas=xidCatcuentas AND catlistas_idCatlistas = xidCatlistas
  18. AND cattemplates_idCattemplates = xidCattemplates AND catusuarios_idCatusuarios = xidCatusuarios
  19. AND asunto = xAsunto
  20. ORDER BY idTbroperacion DESC
  21. LIMIT 1
  22. INTO xIntUltimoRegistro;
  23.  
  24. END IF;
  25.  
  26. INSERT INTO tbrresultado (tbroperacion_idTbroperacion, email, resultado)
  27. VALUES (xIntUltimoRegistro, xEmail, xResultado);
  28.  
  29. SELECT xIntUltimoRegistro AS idTbroperacion;
  30. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement