Error dividing into a function

1
DELIMITER $$
DROP FUNCTION IF EXISTS amountInP $$
CREATE FUNCTION amountInP (euros INTEGER)
RETURNS INTEGER
BEGIN
SELECT amountInP.euros/166.386 AS 'Pessetes' ;
END $$
DELIMITER ;

SELECT amountInP(2000);

I'm doing this function and you're giving me the following error

  #1415 - Not allowed to return a result set from a function

My idea was to pass a number on the screen and divide it by that amount

    
asked by kitkat 09.05.2018 в 13:11
source

1 answer

1

You have to save the result of the statement in a variable and then return it. As follows:

SELECT amountInP.euros/166.386 into {nombre_variable}

Declare the variable previously.

    
answered by 09.05.2018 / 13:20
source