MySQL Forums
Forum List  »  Stored Procedures

Re: stored procedure LIMIT problem
Posted by: Dongkyu Kim
Date: March 27, 2006 03:07AM

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)

Options: ReplyQuote


Subject
Views
Written By
Posted
10236
February 11, 2006 01:06PM
6784
February 13, 2006 10:40AM
4491
February 17, 2006 09:34AM
3741
February 17, 2006 04:35PM
3761
February 18, 2006 10:56AM
Re: stored procedure LIMIT problem
13025
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.