Ver Mensaje Individual
  #7  
Antiguo 16-10-2007
VRO VRO is offline
Miembro
 
Registrado: abr 2004
Posts: 230
Reputación: 21
VRO Va por buen camino
Smile Procedimiento almacenado con fecha

Siento no haberte respondido antes, pero me surgio otro problemailla que he estado intentando resolver ayer de forma frenetica y que aun no he conseguido solucionar.

Decirte que al final pase los parametros fecha como char(20) para que abarque la fecha y la hora, de la siguiente forma:

Código SQL [-]
 
DELIMITER $$
DROP PROCEDURE IF EXISTS `aytosantillana`.`prueba` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `prueba`(IN f1 char(20), IN f2 char(20))
BEGIN
  SET @s = ('SELECT puertos.tag,puertos.dispositivo as disp,valores.fecha,,case puertos.numpuerto when 0 then valores.A0 when 1 then valores.A1 when 2 then valores.A2 when 3 then valores.A3 when 3 then valores.A3 when 4 then valores.A4 when 5 then valores.A5 end as valor from equipos,puertos,valores where ((valores.idEquipo=puertos.idEquipo) and (equipos.idEquipo=puertos.idEquipo) and (equipos.idEquipo=valores.idEquipo) and (valores.fecha >= ' , f1 ,' and valores.fecha<=' ,f2, ') and (puertos.dispositivo<>''Contador'') and (puertos.dispositivo<>''Alimentacion'') and (puertos.dispositivo<>''Temperatura'')  and (puertos.tag<>'''')) having (valor<>'''') order by puertos.dispositivo,valores.idEquipo asc,puertos.numpuerto asc, fecha asc');
  PREPARE stmt FROM @s;
  EXECUTE stmt;
END $$
DELIMITER ;

ahora mi problema es que cuando lo ejecuto me da el error " Operan should contain 1 column", he estado ojeando por los foros, pero no he conseguido dar con la solución seguiré probando, si se te ocurre algo...


Gracias por todo.
Responder Con Cita