I have a more masochistic way to do this without a table

DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`sp_NumberList` $$
CREATE PROCEDURE `test`.`sp_NumberList` (LastNumber INT)
BEGIN
    DECLARE j INT;
    DECLARE SQLPiece TEXT;
    DECLARE SQLStmt TEXT;
    SET j = 0;
    SET SQLStmt = 'SELECT 0 N';
    WHILE j <= LastNumber DO
        SELECT CONCAT(' UNION SELECT ',j) INTO SQLPiece;
        SET j = j + 1;
        SET SQLStmt = CONCAT(SQLStmt,SQLPiece);
    END WHILE;
    SET @s = SQLStmt;
    PREPARE stmt FROM @s;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;
END $$
DELIMITER ;

The highest you can print out is 3700.

Give it a try, and have fun !!!

-----Original Message-----
From: Paul DuBois [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 06, 2008 11:22 AM
To: puntapari; mysql@lists.mysql.com
Subject: Re: function/procedure error!

At 8:05 AM -0800 3/6/08, puntapari wrote:
>Hi!
>
>And returning a list of numbers? It can be and how?

You cannot return a list.  You could generate a result
set in a procedure, but it's returned to the client, not
the caller.

That's why I suggested writing the numbers into a table.
Then you can select from the table.

--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to