Why does this MySQL stored function return null?

PSaR

can anybody explain, why the following MySQL stored function returns always null? If I replace exchange_rate within SET @dollar = euro * exchange_rate; by 1.1013 it works great.

DROP FUNCTION IF EXISTS euro_to_dollar;
DELIMITER $$
CREATE FUNCTION euro_to_dollar(euro double) returns double
BEGIN
  DECLARE dollar double;
  DECLARE exchange_rate double;
  SET @exchange_rate = 1.1013;
  SET @dollar = euro * exchange_rate;
  RETURN @dollar;
END $$
DELIMITER ;
Francisco Romero

You have to make reference to @exchange_rate like this:

DROP FUNCTION IF EXISTS euro_to_dollar;
DELIMITER $$
CREATE FUNCTION euro_to_dollar(euro double) returns double
BEGIN
  DECLARE dollar double;
  DECLARE exchange_rate double;
  SET @exchange_rate = 1.1013;
  SET @dollar = euro * @exchange_rate;
  RETURN @dollar;
END $$
DELIMITER ;

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Why does SSIS lookup return null value?

분류에서Dev

Why does a void function return a value?

분류에서Dev

Why does this MySQL XOR query return 0?

분류에서Dev

Why does UserManager.FindById() return null if I do not relog?

분류에서Dev

PHP Why does the DateTime diff function always return zero?

분류에서Dev

Why MySQL does not return rows in same order as appeared in IN clause?

분류에서Dev

Why does new $class; return null when class_exists($class) returns true?

분류에서Dev

Why won't this MySQL stored procedure work?

분류에서Dev

MySQL stored procedure return variable values from seconds query?

분류에서Dev

why nextelementsibling return null | dom traversing js

분류에서Dev

When does Class#getClassLoader return null?

분류에서Dev

Sub Query - Return NULL, if it does not match the highest

분류에서Dev

Why does SomeStruct() is AnyObject return true?

분류에서Dev

Why does an async method not return the awaitable immediately?

분류에서Dev

Why does egrep -o not return the entire match?

분류에서Dev

Why does my JavaScript instances return the same?

분류에서Dev

Why does stripslashes not return the data without a slash?

분류에서Dev

Why does the error method return an error?

분류에서Dev

How does return work for a function local variable?

분류에서Dev

Why does 'return' and 'yield return' have the same behaviour in this example?

분류에서Dev

Why does this SQL order null values last?

분류에서Dev

Why does my function print '0'?

분류에서Dev

Php recursive function return null while variable have value

분류에서Dev

MYSQL | SP | CURSOR - Fetch cursor into variable return null

분류에서Dev

does mysql have wait or timeout function?

분류에서Dev

When creating a stored procedure in oracle, it appears to execute, but it does nothing. The stored procedure never gets saved. Why?

분류에서Dev

Why does the MBR return a different offset than Ubuntu's commands?

분류에서Dev

Why does indexing bytes in Python 3 return an int instead of bytes?

분류에서Dev

Why does the print(f.close()) return None in the following code?

Related 관련 기사

  1. 1

    Why does SSIS lookup return null value?

  2. 2

    Why does a void function return a value?

  3. 3

    Why does this MySQL XOR query return 0?

  4. 4

    Why does UserManager.FindById() return null if I do not relog?

  5. 5

    PHP Why does the DateTime diff function always return zero?

  6. 6

    Why MySQL does not return rows in same order as appeared in IN clause?

  7. 7

    Why does new $class; return null when class_exists($class) returns true?

  8. 8

    Why won't this MySQL stored procedure work?

  9. 9

    MySQL stored procedure return variable values from seconds query?

  10. 10

    why nextelementsibling return null | dom traversing js

  11. 11

    When does Class#getClassLoader return null?

  12. 12

    Sub Query - Return NULL, if it does not match the highest

  13. 13

    Why does SomeStruct() is AnyObject return true?

  14. 14

    Why does an async method not return the awaitable immediately?

  15. 15

    Why does egrep -o not return the entire match?

  16. 16

    Why does my JavaScript instances return the same?

  17. 17

    Why does stripslashes not return the data without a slash?

  18. 18

    Why does the error method return an error?

  19. 19

    How does return work for a function local variable?

  20. 20

    Why does 'return' and 'yield return' have the same behaviour in this example?

  21. 21

    Why does this SQL order null values last?

  22. 22

    Why does my function print '0'?

  23. 23

    Php recursive function return null while variable have value

  24. 24

    MYSQL | SP | CURSOR - Fetch cursor into variable return null

  25. 25

    does mysql have wait or timeout function?

  26. 26

    When creating a stored procedure in oracle, it appears to execute, but it does nothing. The stored procedure never gets saved. Why?

  27. 27

    Why does the MBR return a different offset than Ubuntu's commands?

  28. 28

    Why does indexing bytes in Python 3 return an int instead of bytes?

  29. 29

    Why does the print(f.close()) return None in the following code?

뜨겁다태그

보관