SQL - Ayuda problema procedimiento

   
Vista:

Ayuda problema procedimiento

Publicado por matitlive (1 intervención) el 20/09/2015 07:38:12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Ayuda problema procedimiento

Publicado por leonardo_josue (877 intervenciones) el 21/09/2015 15:49:10
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.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar