Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/03/2008, 00:45
edu.net
 
Fecha de Ingreso: julio-2004
Ubicación: Montevideo, Uruguay
Mensajes: 9
Antigüedad: 19 años, 9 meses
Puntos: 0
Problema con Store Procedure

Hola estoy teniendo un problema con una SP, siempre que lo ejecuto me tira todos los registros.
Para mi que es el "whereClause" del select, pero se tendría que mostrar bien.
La idea fue crear un SP que sirviera para mostrar noticias publicadas, no-publicadas y todas.
EL parámetro de entrada es: "in inPublicadas bool"

Código del SP:
Código:
DECLARE whereClause VARCHAR(255);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
IF inPublicadas = TRUE THEN
	SET whereClause = "WHERE not_publicada = 1";
ELSEIF inPublicadas = FALSE THEN
	SET whereClause = "WHERE not_publicada = 0";
ELSE SET whereClause = "";
END IF;
SELECT *
FROM noticias
whereClause
ORDER BY not_fecha
;
Script de creación de la tabla:
Código:
CREATE TABLE `noticias` (                                                   
            `not_id` int(11) NOT NULL auto_increment,                                 
            `not_titulo` varchar(255) NOT NULL,                                       
            `not_noticia` text NOT NULL,                                              
            `not_fecha` datetime NOT NULL,                                            
            `not_publicada` tinyint(1) NOT NULL default '0' COMMENT '1 = publicado',  
            PRIMARY KEY  (`not_id`)                                                   
          ) ENGINE=InnoDB DEFAULT CHARSET=latin1
El SP lo llamo con "CALL SelectNoticias(0);" o "CALL SelectNoticias(1);" .... o TRUE o FALSE y siempre me da lo mismo.