Skip to content

Instantly share code, notes, and snippets.

@roniemicro
Created January 11, 2015 12:08
Show Gist options
  • Save roniemicro/bc05a27f29524a695bd8 to your computer and use it in GitHub Desktop.
Save roniemicro/bc05a27f29524a695bd8 to your computer and use it in GitHub Desktop.
Example block for creating function in MySql
CREATE FUNCTION func01(value1 INT , monto DECIMAL (10,2))
RETURNS DECIMAL(10,2)
DETERMINISTIC
BEGIN
DECLARE var_name DECIMAL(10,2);
SET var_name = 0;
SELECT if(value1 = 1,monto *divisa_dolar,monto *divisa_euro) INTO var_name
FROM table
WHERE data_init = 1;
RETURN var_name;
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment