Ver Mensaje Individual
  #19 (permalink)  
Antiguo 03/02/2015, 10:12
lulier19
 
Fecha de Ingreso: enero-2015
Mensajes: 13
Antigüedad: 9 años, 2 meses
Puntos: 0
Respuesta: Crear consultas para base de datos Mysql

Creo que esto funcionaria, ahora mi duda es como puedo comprobar si esta funcion es correcta
Código MySQL:
Ver original
  1. drop function if exists esMatricula;
  2.  
  3. delimiter //
  4. create function esMatricula(cad char(7)) returns int
  5.     DECLARE POS INT DEFAULT 1;
  6.     DECLARE TOTAL CHAR(7) DEFAULT '';
  7.     DECLARE VALOR INT DEFAULT 0;
  8.     DECLARE AUX INT DEFAULT 0; 
  9.  
  10.     REPEAT
  11.         IF (ascii(substring(cad,POS,1))>=48 and ascii(substring(cad,POS,1))<=57) THEN
  12.             SET TOTAL = TOTAL+1;
  13.         END IF;
  14.         SET POS = POS + 1;
  15.     UNTIL POS > 4 END REPEAT;
  16.     REPEAT
  17.         IF (ascii(substring(cad,POS,1))>=65 and ascii(substring(cad,POS,1))<=90) THEN
  18.             SET TOTAL = TOTAL+1;
  19.         END IF;
  20.         SET POS = POS + 1;
  21.     UNTIL POS > 7 END REPEAT;
  22.     if TOTAL=7 then
  23.         set aux=1;
  24.     END IF;
  25.     RETURN AUX;
  26. //
  27. delimiter ;

Última edición por lulier19; 03/02/2015 a las 10:18