Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. DELIMITER $$
  2. CREATE FUNCTION `A`(x int) RETURNS decimal(12,4)
  3.  
  4. DETERMINISTIC
  5. BEGIN
  6.  
  7. DECLARE result Decimal(12, 4);
  8.  
  9. set result = (
  10. SELECT sum(a)
  11. from X where Id = x
  12. );
  13. RETURN result;
  14. END$$
  15.  
  16. DELIMITER $$
  17. CREATE FUNCTION `B`(y) RETURNS decimal(12,4)
  18. DETERMINISTIC
  19. BEGIN
  20.  
  21. DECLARE result Decimal(12, 4);
  22.  
  23. set result = (
  24. SELECT sum(A(X))
  25. from another_something where Id = y
  26. );
  27.  
  28.  
  29. RETURN result;
  30. END$$
  31.  
  32. DELIMITER $$
  33.  
  34. CREATE FUNCTION `C`(z) RETURNS decimal(12,4)
  35. DETERMINISTIC
  36. BEGIN
  37.  
  38. DECLARE result Decimal(12, 4);
  39.  
  40. set result = (
  41. SELECT sum(B(Z))
  42. from another_table where Id = z
  43. );
  44.  
  45.  
  46. RETURN result;
  47. END$$
  48.  
  49. SELECT VERSION();
  50.  
  51. 5.0.96-log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement