document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*
  2.     Autor   : Joel Fernandez
  3.     Fecha   : 08/10/2015
  4.     IDE     : MySQL Workbench
  5.     Web     : www. codebotic.com
  6.     Tema    : FUnciones en MySQL
  7. */
  8. -- 2° crear una calculadora aritmetica
  9. delimiter $$
  10.    
  11.     create function calculadora(op char(1), x int, y int )
  12.     returns float
  13.     begin
  14.         declare operacion float;
  15.         case op
  16.             when \'+\' then set operacion=x+y;
  17.             when \'-\' then set operacion=x-y;
  18.             when \'*\' then set operacion=x*y;
  19.             when \'/\' then set operacion=x/y;
  20.         end case;
  21.         return operacion*1.0;
  22.     end
  23.  
  24. $$
  25.  
  26. select calculadora(\'/\',10,3); -- puede ser +, - , * , /
');