MySQL Forums
Forum List  »  Spanish

Error al ejecutar Stored Procedure
Posted by: alejandro castro mouzo
Date: August 03, 2010 05:18AM

Hola a todos!
He creado un Stored Procedure(el primero que creo en MySQL ya que siempre he trabajado con MS SQL Server 2000) y el Workbench me dice que está correcto y lo ha guardado, el problema viene cuando lo ejecuto, que me da un error en la línea 5...

El Stored Procedure es este:
DELIMITER $$
 
CREATE PROCEDURE `galiciaparty`.`spGetAllEventos` (IN startIndex INT, IN pageSize INT, IN sortBy VARCHAR(30), OUT totalEventos INT)
BEGIN
    DECLARE upperBound INT;
    SET startIndex = IF(startIndex < 1, 1, startIndex);
    SET pageSize = IF(pageSize < 1, 1, pageSize);
    SET upperBound = startIndex + pageSize;
    SET totalEventos=(SELECT Count(*) FROM gp_eventos_prin);
    SET @cnt = 0;
    SET @sqlStatement = CONCAT('SELECT E.id_evento, E.titulo, E.fecha_evento, E.lugar
                               FROM (SELECT *, @cnt := (@cnt + 1) AS row_number
                                     FROM gp_eventos_prin
                                     ORDER BY fecha_evento ASC) AS E
                               WHERE rowNumber >=',startIndex,' AND rowNumber <',upperBound,')');
                               
    PREPARE stmt_name FROM @sqlStatement;
 
    EXECUTE stmt_name;
   
END$$


..............................

Y lo llamo de la siguiente forma:
CALL spGetAllEventos(0,50,"fecha_evento",@cant);

El error que da es el siguiente:
Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 5)


Me lo da tanto en el WORKBENCH como desde C# que es el lenguaje con el que estoy haciendo el programa que accede a la BD...

Me podeis echar un cable para solucionar esto??

Muchas gracias por todo y un Saludo!!

Options: ReplyQuote


Subject
Views
Written By
Posted
Error al ejecutar Stored Procedure
7172
August 03, 2010 05:18AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.