drop table if exists test_table;
create table test_table
(
    id   int auto_increment primary key,
    name varchar(24)
);

insert into test_table
(id, name)
values (1, 'x'),
       (2, 'y'),
       (3, 'z');

create or replace function get_name(_id int) returns varchar(24)
begin
    return (select name from test_table where id = _id);
end;

create or replace view test_view as
select get_name(id) as name
from test_table;

create or replace procedure test_proc()
begin
    declare _cur cursor for
        select 1
        from test_view;

    for row in _cur
        do
            select 1;
        end for;
end;

call test_proc();
call test_proc();
