Re: LIMIT OFFSET with parameters?
Posted by:
Ran Biron
Date: December 26, 2005 02:48PM
I've found a workaround for this problem.
It's ugly, time consuming and... mainly ugly. But it's working.
------SQL--------
DELIMITER $
CREATE PROCEDURE `tmp`()
BEGIN
PREPARE STMT FROM "SELECT * FROM users LIMIT ?,?";
END$
DELIMITER;
SET @a=2;
SET @b=1;
CALL tmp();
EXECUTE STMT USING @a, @b;
------SQL--------
It's tested to be working on 5.0.15.
Hope if helps anyone.
-----EDIT----------
Yet another method, this time not even breaking the SP barrier (security purposes):
....(inside SP)...
SET @String1 = concat(concat(concat(concat("SELECT field1,field2 FROM table1 WHERE field3 = ",sp_var1," && field4 = "),sp_var2," LIMIT "),sp_Var_skip,","),sp_var_count);
PREPARE Stmt FROM @String1;
EXECUTE Stmt;
SET @String1 = ""
......
Edited 1 time(s). Last edit at 12/26/2005 05:31PM by Ran Biron.
Subject
Views
Written By
Posted
15899
June 30, 2005 02:01AM
5293
June 30, 2005 04:59AM
4427
August 12, 2005 10:25AM
4400
August 17, 2005 04:31PM
Re: LIMIT OFFSET with parameters?
5175
December 26, 2005 02:48PM
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.