fork download
  1. CREATE FUNCTION CalculateF()
  2. RETURNS FLOAT
  3. BEGIN
  4. DECLARE x INT;
  5. DECLARE y INT;
  6. DECLARE result FLOAT;
  7.  
  8. -- Obliczenie różnicy dat
  9. SET x = DATEDIFF('2024-12-04', '2024-11-28');
  10. SET y = 4;
  11.  
  12. -- Obliczenie wartości funkcji
  13. SET result = (POWER(x, 2) - POWER(y, 2)) / (x - y);
  14.  
  15. RETURN result;
  16. END;
  17.  
  18. -- Wywołanie funkcji
  19. SELECT CalculateF() AS Result;
  20.  
Success #stdin #stdout #stderr 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: near line 1: near "FUNCTION": syntax error
Error: near line 5: near "DECLARE": syntax error
Error: near line 6: near "DECLARE": syntax error
Error: near line 9: near "SET": syntax error
Error: near line 10: near "SET": syntax error
Error: near line 13: near "SET": syntax error
Error: near line 15: near "RETURN": syntax error
Error: near line 16: cannot commit - no transaction is active
Error: near line 19: no such function: CalculateF