Subject Re: [firebird-support] Recreate indexes
Author Fabiano Bonin
I use this:

set term !! ;

create or alter procedure sp_indices_update
as
declare variable v_index_name varchar(31);
begin
for select
trim(a.rdb$index_name)
from
rdb$indices a
where
coalesce(a.rdb$system_flag, 0) = 0
into
:v_index_name
do
begin
execute statement 'set statistics index ' || v_index_name;
end
end !!

Regards,

Fabiano
On Mon, Jul 14, 2008 at 10:14 AM, Thomas Steinmaurer
<ts@...> wrote:
> Hi Fabio,
>
>> I'm trying to build a little store procedure to rebuild my indexex whenever
>> I want...
>>
>> her3e you are:
>>
>> for select 'ALTER INDEX '||rdb$index_name ||' INACTIVE;'
>> from rdb$indices
>> where rdb$system_flag is null or rdb$system_flag = 0
>> into :COMANDO
>> do EXECUTE STATEMENT :COMANDO;
>>
>> /* ACTIVE Indici */
>> for select 'ALTER INDEX '||rdb$index_name ||' ACTIVE;'
>> from rdb$indices
>> where rdb$system_flag is null or rdb$system_flag = 0
>> into :COMANDO
>> do EXECUTE STATEMENT :COMANDO;
>>
>> I suppose to identify no SYSTEM index using rdb$system_flag is null or
>> rdb$system_flag = 0
>> but if I run it I obtain an error who tell me:
>>
>> This operation is not defined for system tables.
>> unsuccessful metadata update.
>> MODIFY RDB$INDICES failed.
>> action cancelled by trigger (3) to preserve data integrity.
>> Cannot deactivate index used by a PRIMARY/UNIQUE constraint.
>>
>> soem idea?
>
> You can't deactivate the underlaying index of a primary / unique constraint.
>
>
> --
> Best Regards,
> Thomas Steinmaurer
> LogManager Series - Logging/Auditing Suites supporting
> InterBase, Firebird, Advantage Database, MS SQL Server and
> NexusDB V2
> Upscene Productions
> http://www.upscene.com
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>
>