0
我在運行存儲過程時出現語法錯誤,我在+ v_RowIndex +'And('+ v_RowIndex +'+'+ v_NoOfRows +')'附近獲得了語法錯誤;Mysql語法錯誤
任何人都可以幫助我嗎?
DELIMITER //; //
CREATE PROCEDURE GetProducts(v_WhereClause NATIONAL VARCHAR(4000),
v_SortExpression NATIONAL VARCHAR(128),
v_RowIndex INT,
v_NoOfRows INT)
BEGIN
DECLARE v_SQL NATIONAL VARCHAR(4000);
IF (v_WhereClause != '') then
SET v_WhereClause = CONCAT('WHERE ',char(13),v_WhereClause);
end if;
IF (v_SortExpression != '') then
SET v_SortExpression = CONCAT('ORDER BY ',v_SortExpression);
end if;
SET v_SQL = CONCAT('SQLWAYS_EVAL# AS (
SELECT ROW_NUMBER() OVER (',v_SortExpression,
'SQLWAYS_EVAL#
[Id],
[Name],
[Description],
[Unit],
[UnitPrice],
[CreateDate]
FROM
[Product]
',v_WhereClause,'SQLWAYS_EVAL#
Row between ')+v_RowIndex+' And ('+v_RowIndex+' + '+v_NoOfRows+')';
SET @SWV_Stmt = v_SQL;
PREPARE SWT_Stmt FROM @SWV_Stmt;
EXECUTE SWT_Stmt;
DEALLOCATE PREPARE SWT_Stmt;
SET v_SQL = CONCAT('SELECT COUNT(Id)
FROM
Product ',v_WhereClause);
SET @SWV_Stmt = v_SQL;
PREPARE SWT_Stmt FROM @SWV_Stmt;
EXECUTE SWT_Stmt;
DEALLOCATE PREPARE SWT_Stmt;
END;
//
嗯非法的,我不知道怎麼回事,寫劇本。我可以管理刪除方括號,但窗口功能:( – user689265 2011-04-04 09:22:13
您可以在StackOverflow上執行搜索有幾個替代MySQL的rowarumber()函數替代方法。 – 2011-04-04 09:56:53