Advertisement
jacknpoe

Function with Transaction Problem

Jun 10th, 2016 (edited)
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.95 KB | None | 0 0
  1. ###### FUNCTION   DOES WORK  (FUNCIONA)
  2. DELIMITER |
  3. CREATE OR REPLACE FUNCTION TesteFunction() RETURNS INT DETERMINISTIC MODIFIES SQL DATA
  4. BEGIN
  5.     DECLARE Retorno INT;
  6.  
  7.     UPDATE Produto SET CD_Extra = "CD00472-5" WHERE CD_Codigo = 6;
  8.     SELECT ROW_COUNT() INTO Retorno;
  9.  
  10.     RETURN Retorno;
  11. END |
  12.  
  13.  
  14. ###### PROCEDURE WITH TRANSACTION   DOES WORK  (FUNCIONA)
  15. DELIMITER |
  16. CREATE OR REPLACE PROCEDURE TesteFunction() DETERMINISTIC MODIFIES SQL DATA
  17. BEGIN
  18.     START TRANSACTION READ WRITE;
  19.     UPDATE Produto SET CD_Extra = "CD00472-5" WHERE CD_Codigo = 6;
  20.     SELECT ROW_COUNT();
  21.     COMMIT;
  22. END |
  23.    
  24.  
  25. ###### FUNCTION WITH TRANSACTION   DOESN'T WORK  (NÃO FUNCIONA)
  26. DELIMITER |
  27. CREATE OR REPLACE FUNCTION TesteFunction() RETURNS INT DETERMINISTIC MODIFIES SQL DATA
  28. BEGIN
  29.     DECLARE Retorno INT;
  30.  
  31.     START TRANSACTION READ WRITE;
  32.     UPDATE Produto SET CD_Extra = "CD00472-5" WHERE CD_Codigo = 6;
  33.     SELECT ROW_COUNT() INTO Retorno;
  34.     COMMIT;
  35.  
  36.     RETURN Retorno;
  37. END |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement