views:

20

answers:

1

I'm importing a stored procedure which I just exported from my development server into my production one and I ran into the following error in phymyadmin.

SQL query: Documentation

$$ CREATE DEFINER = `devuser`@`localhost` FUNCTION `get_refundable_amount` (
enrol_id INT
) RETURNS double( 10, 2 ) READS SQL DATA BEGIN DECLARE refundable_amount double( 10, 2 ) DEFAULT 0;

SELECT (
sum( P.amount ) - EI.amount
)
INTO refundable_amount
FROM site_payment_processed AS P
INNER JOIN site_user_enroled AS E ON ( P.enrol_id = E.id
AND P.payment_type = 'Refund' )
INNER JOIN site_user_enroled_invoice AS EI ON EI.enrol_id = E.id
WHERE E.id = enrol_id
GROUP BY E.id;

RETURN (
refundable_amount
);

END$$

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$

CREATE DEFINER=`devuser`@`localhost` FUNCTION `get_refundable_amount`' at line 1 
A: 

Solution presented in http://stackoverflow.com/questions/3831077/creating-functions-in-mysql-doesnt-work-error-1064 suffices completely.

The issue was with phpMyAdmin. Running from the mysql command line worked fine.

matt_tm