TheLazyPig
Programmer
Hi!
I tried to create a new function in phpmyadmin that I copied the structures from other functions in the database but I get this error.
Thanks in advance!
I tried to create a new function in phpmyadmin that I copied the structures from other functions in the database but I get this error.
Code:
CREATE DEFINER =`root`@`%` FUNCTION `fnGetGrpLoanFaceAmt`(`polno` VARCHAR(20),`poc_no` INT) RETURNS decimal(11,2)
BEGIN
DECLARE ben_value DECIMAL(11,2);
SET ben_value = (SELECT IF(SUM(ROUND(ben.VALUE,2)) IS NULL, 0, SUM(ROUND(ben.VALUE,2)))
FROM `group`.master_policy mp
LEFT JOIN `group`.policy_certificates pc ON pc.master_policy_id = mp.ID
LEFT JOIN `group`.loan_multi loan ON loan.master_policy_id = mp.id AND loan.certificate_no = pc.certificate_no
LEFT JOIN `group`.benefits ben ON ben.master_policy_id = mp.id AND ben.benefit_id = loan.benefits_id
LEFT JOIN `group`.premium_breakdown pb ON pb.master_policy_id = mp.ID AND pb.breakdown_id = loan.prem_breakdown_id
WHERE 1 = 1
AND mp.policy_no = polno
AND pc.poc_no = poc_no
AND (loan.loan_status = 5 OR loan.loan_status = 'I' OR (pc.status_date BETWEEN ben.effective_date AND ben.termination_date))
ORDER BY ben.termination_date DESC
);
RETURN ben_value;
END
Thanks in advance!