использование переменной во вложенных курсорах - PullRequest
0 голосов
/ 01 июля 2019

У меня есть фрагмент хранимой процедуры, подобный этому

 CREATE DEFINER=`root`@`%` PROCEDURE `new_procedure`()
    BEGIN
    DECLARE c_id varchar(100) DEFAULT "";
    DECLARE cursor1 CURSOR  for select id from t1 where name like 's%';
    OPEN cursor1;
    get_t1: LOOP
        FETCH cursor1 into c_id;
        p:begin
        declare cursor2 cursor for select id from t2 where cl_id=c_id;
        open cursor2;
        get_t2: loop
        fetch project_cursor into p_id;
                // perform some tasks
                t:begin
                  declare cursor3 cursor for select id from t3 where pr_id=p_id;
            open cursor3;
            get_t3:loop
                fetch cursor3 into t_id;
                IF v_finished = 1 THEN 
                LEAVE get_t3;
                END IF;
                //perform some tasks
            close cursor3;
            select p_id;
            end t;
end loop t2;    
    end p;
END LOOP t1;
END

здесь оператор select не отображает никаких данных

когда я пишу select под курсором 3, он работает.

я сделал ошибку?все, что я пропустил

...