SET TERM ^ ;

CREATE OR ALTER procedure PROC_ATIVAR_INDICE
as
declare variable STMT varchar(1000);
begin
 FOR SELECT 'alter index '||rdb$index_name ||' active;'
      FROM rdb$indices
      where rdb$index_inactive=1
          and (not rdb$index_name like 'FK%')
          and rdb$unique_flag=0
 INTO :stmt do
     EXECUTE statement :stmt;


 FOR SELECT 'alter index '||rdb$index_name ||' active;'
     FROM rdb$indices
     where rdb$index_inactive=1
           and (not rdb$index_name like 'FK%')
           and rdb$unique_flag=1
   INTO :stmt do
     EXECUTE statement :stmt;


 FOR SELECT 'alter index '||rdb$index_name ||' active;'
     FROM rdb$indices
     where rdb$index_inactive=1
           and (rdb$index_name like 'FK%')
    INTO :stmt do
     EXECUTE statement :stmt;


end^

SET TERM ; ^

