After the mysql-MYSQL cursor REPEAT loop, the string return value cannot be obtained. Thank you!

Source: Internet
Author: User
I have a data table zq + ------- + -------- + Trend + --------- + -------- + --------- + | zq_id | zq_dm | zq_mc | zqlx_id | fllx_id | jys_id | region | + ------- + -------- + -------------- + --------- + -------- + --------- + | 1 | 000001 | Ping An Bank | 4 |... mysql return value delphi stored procedure loop

I have a data table zq.

+ ------- + -------- + Strong + --------- + -------- + --------- + | zq_id | zq_dm | zq_mc | zqlx_id | fllx_id | jys_id | strong | + ------- + -------- + ------- + --------- + -------- + --------- + | 1 | 000001 | Ping An Bank | 4 | 9 | 1 | 1 | 2 | 113001 | Bank of China convertible bonds | 4 | 9 | 1 | 1 | 3 | 113005 | safe debt | 4 | 9 | 1 | 4 | 131800 | R-003 | 3 | 5 | 2 | 0 | 5 | 131801 | R-007 | 3 | 7 | 2 | 0 | 6 | 131802 | R-014 | 3 | 8 | 2 | 0 | 7 | 131809 | R-004 | 3 | 6 | 2 | 0 | 8 | 131810 | R-001 | 3 | 3 | 2 | 1 | 9 | 131811 | R-002 | 3 | 4 | 2 | 0 | 10 | 150124 | Jianxin 50B | 5 | 10 | 2 | 0 | 11 | 510300 | 600893 ETF | 2 | 2 | 1 | 0 | 12 | 601318 | aviation power | 1 | 1 | 1 | 0 | 13 | Ping An, China | 1 | 1 | 1 | 1 | 14 | 601872 | merchants ships | 1 | 1 | 1 | 1 | + ------- + -------- + -------------- + --------- + -------- + --------- +

There is also a data table jys

+ -------- + --------------------- + | Jys_id | jys_dm | jys_mc | + -------- + ----------------------- + | 1 | SH | Shanghai stock exchange | 2 | SZ | Shenzhen Stock Exchange | + -------- + ----------------------- +

I want to extract the zq_dm field of the record whose field zq_cxhq is 1 in the zq table and the corresponding jys_dm to form a string. the expected result is the string "sh201701, SH113001, SH113005, SZ131810, SH601318, SH601872 ,".

My method is:

CREATE DEFINER=`root`@`localhost` PROCEDURE `routine_Sshq`(  OUT jyszqdm VARCHAR(100))BEGIN  DECLARE zqdm VARCHAR(45);    DECLARE jysdm VARCHAR(45);  DECLARE jyszq VARCHAR(100);  DECLARE done TINYINT(1) DEFAULT 0;  DECLARE cur_zqhq  CURSOR FOR SELECT zq_dm, jys_dm    FROM zq    LEFT JOIN jys    ON jys.jys_id = zq.jys_id    WHERE zq_cxhq = 1;  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;  OPEN cur_zqhq;  REPEAT    FETCH cur_zqhq INTO zqdm, jysdm;    IF done = 0 THEN      SET jyszq = CONCAT(jyszq, jysdm, zqdm, ',');    END IF;  UNTIL done = 1 END REPEAT;  SET jyszqdm  = jyszq;END

In DELPHI XE2, I assigned the returned value of this stored procedure to the Edit control, but it never succeeded.
I changed the last row of the stored procedure to SET jyszqdm = 'abc.
I doubt whether the previous REPEAT loop is not over yet? However, the cause cannot be found.

I am a self-taught Cainiao. I hope you will be able to advise me. Thank you very much.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.