I have a dynamic query being created in sql like this:
set sql_statement= concat( 'declare cursor_get_crm_org_metadata_ids cursor for select ’ , current_crm_org_uuid_name, '.crm_erorr_metadata.id into from ’ , current_crm_org_uuid_name, '.crm_erorr_metadata where ', current_crm_org_uuid_name , '.crm_erorr_metadata.object_error_count > 0 order by ', current_crm_org_uuid_name, ‘.crm_erorr_metadata.id’);
set @sql= sql_statement;
prepare stmt from @sql;
execute stmt;
but i keep getting
Error Code: 1324. Undefined CURSOR: cursor_get_crm_org_metadata_ids
does anyone have an idea? The stackoverflow solutions don’t work at all.