Subject Re: [firebird-support] REBUILDING the INDEXES in Firebird
Author Alexandre Benson Smith
Ivan Cruz wrote:

>Note: since ALTER INDEX is a DDL command it cannot be used
>inside a stored procedure.
>
>
unless one use the EXECUTE STATEMENT

I have an SP like this:
CREATE PROCEDURE THOR_ATUALIZAESTATISTICAINDICE RETURNS
(
INDEXNAME VARCHAR(255)
)
AS
begin
for
select
cast(rdb$Index_Name as varchar(255))
from
rdb$Indices
into
:IndexName
do begin
execute statement 'set statistics index ' || :IndexName;
IndexName = IndexName || ' estatistica atualizada';
suspend;
end
end

and then do it to update the statistcs:

select * from THOR_ATUALIZAESTATISTICAINDICE

>Ivan.
>
>
see you !

--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br