Hi,

MySQL function below is not working. I cant find the mistake. Can you help me?

Thanks

CREATE FUNCTION testVAT(DECIMAL(4,2))
RETURNS DECIMAL(4,2)
DETERMINISTIC
BEGIN
	DECLARE myVAT DECIMAL;
		SET myVAT = (myMoney * 0.17);
	RETURN myVAT;
END;

Where does myMoney come from???? I think you missed it in the function declaration line

Yes you are right. It must be CREATE FUNCTION testVAT(myMoney DECIMAL(4,2)) . But, still doesn't work.

i don't know what isn't working

in your declare for myVAT specify the the length

DECLARE myVAT DECIMAL(4,2)

is the problem a rounding problem? or what doesn't work about it?

what happens you try to run it?

I will try it again and let you know what exactly error was.
Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.