Determine what datatypes you want.
INT
won't work so hot with your 1.16 idea. You lose to rounding to an INT. The below does not use INT
DROP FUNCTION IF EXISTS CalculoIVA;
DELIMITER $$
CREATE FUNCTION CalculoIVA
(x DECIMAL(12,4))
RETURNS DECIMAL(12,4)
DETERMINISTIC
BEGIN
DECLARE IVA DECIMAL(12,4); -- OR FLOAT etc
SET IVA = x *1.16;
RETURN IVA;
END;$$
DELIMITER ;
select CalculoIVA(9.12);
-- 10.5792
If you want the datatypes to be
DECIMAL(12,2)
or FLOAT
just make the necessary changes.
Note: the DELIMITER wrapper is unnecessary for PHPMyAdmin users.
0 Comments