MySQL Cursor with Distinct返回太多行

时间:2018-01-20 19:24:23

标签: mysql

我有以下程序:

delimiter $$
CREATE PROCEDURE create_default_apps()
BEGIN
    DECLARE done INT DEFAULT 0;
    DECLARE v_app_nm VARCHAR(100);
    DECLARE v_app_typ VARCHAR(10);
    DECLARE v_employer_id VARCHAR(25);
    DECLARE existing_apps cursor for select distinct APP_NM, EMPLOYER_ID, APP_TYP from USER_APP;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
    open existing_apps;
    create_default_apps: LOOP
        fetch existing_apps into v_app_nm, v_employer_id, v_app_typ;
        insert into APP(ID, APP_NM, EXTERNAL_ID, APP_TYP, LAST_CHANGED_DT, LAST_CHANGED_BY, CREATED_DT, CREATED_BY) values(UNHEX(REPLACE(UUID(), '-', '')), v_app_nm, v_employer_id, v_app_typ, sysdate(), 'testuser', sysdate(), 'testuser');
    end loop create_default_apps;
    close existing_apps;
END$$

USER_APP表中只有85行,但由于某种原因,当我运行此过程时,它会一直运行,直到我手动终止它,就好像“select distinct”返回的多,超过85行。我只是错过了一些非常明显的东西吗?

1 个答案:

答案 0 :(得分:1)

尝试:

<a class="Button" href="https://xyz.cdf/abc" onclick="ABC_A('xpid',':xyz:cdf',this.href);  return false;">Button Click</a>