Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/11/2015, 15:30
valalmeida
 
Fecha de Ingreso: noviembre-2015
Ubicación: chile
Mensajes: 5
Antigüedad: 8 años, 6 meses
Puntos: 0
Respuesta: problema con if en procedimeinto almacenado

Probé tu código pero ahora no inserta ninguna fila (con o sin idsoc repetido)

mysql> create procedure insertarUsuario(nick1 varchar(20),password1 varchar(8),idSoc1 int(11))
-> begin
-> declare total int;
-> select @total:= count(IDSOC) from usuario where NICK = nick1;
-> if total<2 then
-> insert into usuario (NICK,PASSWORD,IDSOC) values(nick1,password1,idSoc1);
-> end if;
-> commit;
-> end;
-> //
Query OK, 0 rows affected (0.00 sec)

mysql> call insertarUsuario('naty','1234',6);
-> //
+-----------------------+
| @total:= count(IDSOC) |
+-----------------------+
| 3 |
+-----------------------+
Gracias por intentar :)