Rumah  >  Artikel  >  pembangunan bahagian belakang  >  MySQL 存储过程,参数无效,求解

MySQL 存储过程,参数无效,求解

WBOY
WBOYasal
2016-06-06 20:50:251601semak imbas

<code>    DROP PROCEDURE IF EXISTS market.app_get_list;
    DELIMITER //

    CREATE PROCEDURE market.app_get_list(IN orders VARCHAR(20), IN type TINYINT, IN offset INT, IN rows INT)
    BEGIN
        DECLARE done INT DEFAULT 0;
        DECLARE pack VARCHAR(40);
        DECLARE packages CURSOR FOR SELECT DISTINCT package FROM market_app ORDER BY orders DESC LIMIT offset, rows;
        DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; 

    OPEN packages;

    REPEAT
        FETCH packages INTO pack;
        IF NOT done THEN
            SELECT * FROM market_app WHERE package = pack ORDER BY versioncode DESC LIMIT 1;
        END IF;
    UNTIL done END REPEAT;

    CLOSE packages;
END//

    DELIMITER ;
</code>

现在参数orders不起作用,麻烦懂的人帮忙修改下,谢谢哈。

回复内容:

<code>    DROP PROCEDURE IF EXISTS market.app_get_list;
    DELIMITER //

    CREATE PROCEDURE market.app_get_list(IN orders VARCHAR(20), IN type TINYINT, IN offset INT, IN rows INT)
    BEGIN
        DECLARE done INT DEFAULT 0;
        DECLARE pack VARCHAR(40);
        DECLARE packages CURSOR FOR SELECT DISTINCT package FROM market_app ORDER BY orders DESC LIMIT offset, rows;
        DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; 

    OPEN packages;

    REPEAT
        FETCH packages INTO pack;
        IF NOT done THEN
            SELECT * FROM market_app WHERE package = pack ORDER BY versioncode DESC LIMIT 1;
        END IF;
    UNTIL done END REPEAT;

    CLOSE packages;
END//

    DELIMITER ;
</code>

现在参数orders不起作用,麻烦懂的人帮忙修改下,谢谢哈。

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn