Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » SQL Server »

Problema procedimiento

Estas en el tema de Problema procedimiento en el foro de SQL Server en Foros del Web. Código: use l2jdb; DROP procedure IF EXISTS `BorrarSkills`; DELIMITER $$ use l2jdb$$ CREATE PROCEDURE BorrarSkills (chname varchar(35)) BEGIN Declare idchar decimal(11,0); Declare haveskills int(11); Declare ...
  #1 (permalink)  
Antiguo 20/09/2015, 00:02
 
Fecha de Ingreso: agosto-2015
Mensajes: 20
Antigüedad: 8 años, 7 meses
Puntos: 0
Problema procedimiento

Código:
use l2jdb;
DROP procedure IF EXISTS `BorrarSkills`;
 
DELIMITER $$
use l2jdb$$
 
CREATE PROCEDURE BorrarSkills (chname varchar(35))
BEGIN
Declare idchar decimal(11,0);
Declare haveskills int(11);
Declare i int(1);
Declare skill_id1 int(3);
Declare skill_id2 int(3);
Declare skill_id3 int(3);
Declare level1 int(2);
Declare level2 int(2);
Declare level3 int(2);
#SET idlight1=(select skill_id from character_skill where skill_id=236 and obj_id=idchar);
SET idchar = (select obj_id from  characters where char_name = chname);
SET skill_id1=(select skill_id from character_skills where char_obj_id=idchar and skill_id=236);
SET skill_id2=(select skill_id from character_skills where char_obj_id=idchar and skill_id=252);
SET skill_id3=(select skill_id from character_skills where char_obj_id=idchar and skill_id=258);
#231, 232, 253,259 HEAVY ARMOR MASTERY
# LIGHT ARMOR MASTERY 236, 258, 252
#234,235,251 ROBE MASTERY
if idchar > 1  then
SET i=0;
	if skill_id1=236 then
		set i = i+1;
		set level1=(select skill_level from character_skills where skill_id=236 and char_obj_id=idchar);
	END if
	 if skill_id2=252 then
		set  i = i+1;
		set level2=(select skill_level from character_skills where skill_id=252 and char_obj_id=idchar);
	END if
	 if skill_id3=258 then
		set i=i+1;
		set level3=(select skill_level from character_skills where skill_id=258 and char_obj_id=idchar);
	END if
	if i<1 then
		if level1>level2 then
			delete from character_skills where skill_id=236 and char_obj_id=idchar;
		else if level2>level1 then
			delete from character_skills where skill_id=252 and char_obj_id=idchar;
		else if level1>level3 then
			delete from character_skills where skill_id=236 and char_obj_id=idchar;
		else if level3>level1 then
			delete from character_skills where skill_id=258 and char_obj_id=idchar;
		else if level3>level2 then
			delete from character_skills where skill_id=258 and char_obj_id=idchar;
		else if level2>level3 then
			delete from character_skills where skill_id=252 and char_obj_id=idchar;
	END IF
END IF
END$$
 
DELIMITER ;
Y me da este error querer crearla:
[Err] 1064 - Erreur de syntaxe près de 'if skill_id2=252 then
set i = i+1;
set level2=(select skill_level from ch' à la ligne 26
  #2 (permalink)  
Antiguo 21/09/2015, 12:15
Avatar de iislas
Colaborador
 
Fecha de Ingreso: julio-2007
Ubicación: Mexico, D.F.
Mensajes: 6.482
Antigüedad: 16 años, 8 meses
Puntos: 180
Respuesta: Problema procedimiento

¿En que motor de base de datos?
__________________
MCTS Isaias Islas
  #3 (permalink)  
Antiguo 21/09/2015, 12:18
Avatar de iislas
Colaborador
 
Fecha de Ingreso: julio-2007
Ubicación: Mexico, D.F.
Mensajes: 6.482
Antigüedad: 16 años, 8 meses
Puntos: 180
Respuesta: Problema procedimiento

Es MYSQL, deberías ponerlo en ese grupo y ya te dieron una respuesta en LWDP

Hola matitlive:

Checa la documentación oficial de MySQL: Te falta poner un punto y coma (;) en el END IF

https://dev.mysql.com/doc/refman/5.0/en/if.html

Haz la prueba y nos comentas.

Saludos
Leo.
__________________
MCTS Isaias Islas

Etiquetas: procedimiento, select
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:31.