create or replace procedure prc_26ai_query_run_insight_pending(p_synthesizespeech in varchar2)
as

begin
  for r1 in ( select query_id
              from TB_26AI_QUERY_HISTORY
              where RUN_SQL_DATE is null
              order by REGISTER_DATE
            ) loop

    prc_26ai_query_run_insight( r1.query_id , p_synthesizespeech );

    update TB_26AI_QUERY_HISTORY
    set RUN_SQL_DATE = sysdate
    where query_id = r1.query_id ;

    commit;

  end loop;
end;
/