Skip to content

Instantly share code, notes, and snippets.

@nawawi
Created March 20, 2015 14:55
Show Gist options
  • Save nawawi/19bba9230fcf7e9da96c to your computer and use it in GitHub Desktop.
Save nawawi/19bba9230fcf7e9da96c to your computer and use it in GitHub Desktop.
contoh duit masuk dan keluar
-- function duit masuk simpan dalam sen
-- contoh guna: INSERT INTO `test` (`duit`) VALUES ( duitmasuk('1.20') );
CREATE FUNCTION `duitmasuk`(`num` FLOAT) RETURNS int(11)
DETERMINISTIC
RETURN ( num * 100 )
-- function duit keluar dalam ringgit
-- conth guna: SELECT duitkeluar(duit) as duit FROM `test`
CREATE FUNCTION `duitkeluar`(num INT) RETURNS float
DETERMINISTIC
RETURN ( num / 100 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment