Re: stored procedure LIMIT problem
You can use 'user variable' in stored procedure
to use your parameter.
For example, Andrew's code could be converted like this;
DELIMITER //
DROP PROCEDURE randomtest;//
CREATE PROCEDURE randomtest (mcode CHAR(5), ttle VARCHAR(30), lmt INT)
BEGIN
-- Set user variables!!!
SET @mcode = mcode;
SET @ttle = ttle;
SET @lmt = lmt;
PREPARE STMT FROM "SELECT distinct * FROM grp WHERE modulecode = ? AND grpcategory = ? ORDER BY RAND() LIMIT ?";
EXECUTE STMT USING @mcode, @ttle, @lmt;
END;
//
-------------------------------
Dongkyu Kim (superkdk at superkdk.com)
Subject
Views
Written By
Posted
10244
February 11, 2006 01:06PM
6786
February 13, 2006 10:40AM
4493
February 17, 2006 09:34AM
4014
February 16, 2006 08:02PM
3743
February 17, 2006 04:35PM
3583
February 18, 2006 10:07AM
3767
February 18, 2006 10:56AM
3716
February 18, 2006 11:52AM
Re: stored procedure LIMIT problem
13029
March 27, 2006 03:07AM
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.