Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Bases de datos > MySQL
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 29-03-2013
teecweb teecweb is offline
Miembro
NULL
 
Registrado: feb 2013
Posts: 64
Poder: 12
teecweb Va por buen camino
Problema con este function en mysql

Tengo una consulta que al ejecutra en el servidor me ocurre este error
me sale el error de mysql 1024..lo que me parece ma extraño al ejecutar localmente me ejecuta normalmente ..gracias por tu respuesta

Código SQL [-]
CREATE DEFINER=`root`@`localhost` FUNCTION `RomanToInteger`(
  `xstrRoman` varchar(4)
) RETURNS int(11)
BEGIN        
   DECLARE xi INT;
   DECLARE xstrCharacther CHAR(30);
   DECLARE xintResult INT;
   DECLARE xintNewValue INT;
   DECLARE xintOldValue INT;

   SET xstrRoman = UPPER(xstrRoman);
   SET xintOldValue = 1000;
   SET xintNewValue = 0;
   SET xintResult = 0;
   SET xi=1;  

   WHILE (xi<= length(xstrRoman)) DO
     SET xstrCharacther = SUBSTRING(xstrRoman, xi, 1);    

     CASE xstrCharacther
      WHEN 'I' THEN SET xintNewValue = 1;
      WHEN 'V' THEN SET xintNewValue = 5;
      WHEN 'X' THEN SET xintNewValue = 10;
      WHEN 'L' THEN SET xintNewValue = 50;
      WHEN 'C' THEN SET xintNewValue = 100;
      WHEN 'D' THEN SET xintNewValue = 500;
      WHEN 'M' THEN SET xintNewValue = 1000;
     END CASE;
  
    IF xintNewValue > xintOldValue THEN
      SET xintResult = xintResult + xintNewValue - 2 * xintOldValue;
    ELSE
      SET xintResult = xintResult + xintNewValue;
    END IF;
    SET xintOldValue = xintNewValue;
    SET xi=xi+1;
  
 END WHILE;
    Return xintResult;
END
Archivos Adjuntos
Tipo de Archivo: rar sd4.rar (15,7 KB, 0 visitas)

Última edición por teecweb fecha: 29-03-2013 a las 00:43:57.
Responder Con Cita
  #2  
Antiguo 29-03-2013
teecweb teecweb is offline
Miembro
NULL
 
Registrado: feb 2013
Posts: 64
Poder: 12
teecweb Va por buen camino
Error al ejecutar una consulta en mysql

Holas.. eh ejecutado una consulta en mysql remotamente y me bota el error 1024 pero al ejecutar localmente me corre normalmente le envio el codigo original..abajo le envio un zip mostrando la imagen..gracias por sus respuestas

Código SQL [-]


DELIMITER $$
CREATE DEFINER=`usermysql`@`localhost` FUNCTION `RomanToInteger`(
  `xstrRoman` varchar(4)
) RETURNS int(11)
BEGIN        
   DECLARE xi INT;
   DECLARE xstrCharacther CHAR(30);
   DECLARE xintResult INT;
   DECLARE xintNewValue INT;
   DECLARE xintOldValue INT;

   SET xstrRoman = UPPER(xstrRoman);
   SET xintOldValue = 1000;
   SET xintNewValue = 0;
   SET xintResult = 0;
   SET xi=1;  

   WHILE (xi<= length(xstrRoman)) DO
     SET xstrCharacther = SUBSTRING(xstrRoman, xi, 1);    

     CASE xstrCharacther
      WHEN 'I' THEN SET xintNewValue = 1;
      WHEN 'V' THEN SET xintNewValue = 5;
      WHEN 'X' THEN SET xintNewValue = 10;
      WHEN 'L' THEN SET xintNewValue = 50;
      WHEN 'C' THEN SET xintNewValue = 100;
      WHEN 'D' THEN SET xintNewValue = 500;
      WHEN 'M' THEN SET xintNewValue = 1000;
     END CASE;
  
    IF xintNewValue > xintOldValue THEN
      SET xintResult = xintResult + xintNewValue - 2 * xintOldValue;
    ELSE
      SET xintResult = xintResult + xintNewValue;
    END IF;
    SET xintOldValue = xintNewValue;
    SET xi=xi+1;
  
 END WHILE;
    Return xintResult;
END
Archivos Adjuntos
Tipo de Archivo: rar sd4.rar (15,7 KB, 3 visitas)
Responder Con Cita
  #3  
Antiguo 29-03-2013
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.039
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Por favor, deja de repetir hilos, gracias.
Responder Con Cita
  #4  
Antiguo 29-03-2013
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.039
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Puedes copiar el mensaje y te ahorras de estar pegando imágenes:

Cita:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version the right syntax to use near '=1;
Responder Con Cita
  #5  
Antiguo 29-03-2013
teecweb teecweb is offline
Miembro
NULL
 
Registrado: feb 2013
Posts: 64
Poder: 12
teecweb Va por buen camino
Disculpe pero no estoy repitiendo hilos..solo es una nueva pregunta..gracias
Responder Con Cita
  #6  
Antiguo 29-03-2013
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.039
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Cita:
Empezado por teecweb Ver Mensaje
Disculpe pero no estoy repitiendo hilos..solo es una nueva pregunta..gracias
Estás repìtiendo hilos. ¿Acaso no son iguales los 2 mensajes de arriba?, estaban en hilos distintos, en foros distintos, y los he unidos.
Responder Con Cita
  #7  
Antiguo 29-03-2013
teecweb teecweb is offline
Miembro
NULL
 
Registrado: feb 2013
Posts: 64
Poder: 12
teecweb Va por buen camino
No me habia fijado solo que primera vez que quize enviar el primer mensaje y quize editar me salio que ya no podia editar y no salio el mensaje y por eso lo hize otra vez ..y lo mande..mi intencion no era enredar con muchos hilos ..solo mandar mi pregunta y respetar las reglas del foro..igualmente gracias..
Responder Con Cita
  #8  
Antiguo 29-03-2013
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.039
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
No hay problema, en todo caso para otra vez, puedes pedir a cualquier moderador que te lo edite. Gracias
Responder Con Cita
  #9  
Antiguo 29-03-2013
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.039
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Creo que el error lo tienes aquí:
Código SQL [-]
end if;  /* ¿ sobra el if ? */
Supongo que será sólo end, sin el if, eso es de basic.
Responder Con Cita
  #10  
Antiguo 29-03-2013
teecweb teecweb is offline
Miembro
NULL
 
Registrado: feb 2013
Posts: 64
Poder: 12
teecweb Va por buen camino
No creo cuando lo quito me sale error de sintaxis..
Responder Con Cita
  #11  
Antiguo 29-03-2013
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.039
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Cita:
Empezado por teecweb Ver Mensaje
No creo cuando lo quito me sale error de sintaxis..
Y si lo dejas, también
Responder Con Cita
  #12  
Antiguo 29-03-2013
teecweb teecweb is offline
Miembro
NULL
 
Registrado: feb 2013
Posts: 64
Poder: 12
teecweb Va por buen camino
El error es por por el case..no por el if segun veo la imagen que envie..el en if si lo kito me sale error y sino esta bien ,,gracias
Responder Con Cita
  #13  
Antiguo 29-03-2013
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.039
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
¿Has visto algún tutorial mysql?, ahí puedes confirmar cómo es la sintaxis.
Te pego tu imagen.


Última edición por Casimiro Notevi fecha: 29-03-2013 a las 02:08:02.
Responder Con Cita
  #14  
Antiguo 29-03-2013
teecweb teecweb is offline
Miembro
NULL
 
Registrado: feb 2013
Posts: 64
Poder: 12
teecweb Va por buen camino
aqui le envio el pantallazo de la sintaxis..gracias

ui.jpg

ui.rar
Responder Con Cita
  #15  
Antiguo 29-03-2013
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.039
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
En lugar de pegar imágenes que no sirven de mucho, haz un copia pega del código y usa las etiquetas.
Recuerda poner los tags al código fuente, ejemplo:



Gracias
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Problema con function Pos() Anel Hernandez Varios 2 12-11-2012 19:30:27
Problema con la function date... georkis PHP 2 20-12-2010 17:33:56
Ayuda con este problema emiliano_b OOP 36 25-07-2010 03:36:27
que problema hay con este comando ElDioni SQL 5 14-07-2005 12:49:14
Ayudenme con este Error de Mysql 4.1 Dicdi MySQL 1 19-04-2005 23:27:56


La franja horaria es GMT +2. Ahora son las 07:17:30.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi