Subject RE: [firebird-support] Re: Update RDB$INDICES
Author Thomas Steinmaurer
David,

> > > I'm using FB1.5 for Linux.
> > >
> > > Is is possible (or desirable) to perform:
> > >
> > > 'UPDATE RDB$INDICES SET RDB$INDEX_INACTIVE = 0'
> >
> > Theoretically yes, but practically no. ;-)
> >
> > First of all, updating the system tables directly when there is
> > an equivalent DDL statement, is a bad thing.
> >
> > And second, you've to activate the indices in the right order.
> > For instance, you've to activate an index of a primary key
> > constraint before activating an index used in a foreign key
> > which refers to that primary key.
> >
> > Rearrange these statements manually and execute that
> > script against your database.
>
> Thomas,
>
> I couldn't agree with you more! I just posted to the list regarding
> my "excitement" earlier today trying to bring my database back from
> the dead.

You could give the following selectable stored procedure
a try. This will generate the DDL script to activate
inactive indices "on-the-fly" for you.

SET TERM ^^ ;
CREATE PROCEDURE PRO_GETINDEXACTIVATESCRIPT returns (
DDL VarChar(255))
AS
declare variable index_name varchar(31);
begin
/* get non FOREIGN-KEY related indices first */
for
select rdb$index_name from RDB$INDICES
where (rdb$index_inactive = 1) and (rdb$system_flag = 0 or rdb$system_flag is null) and (rdb$foreign_key is null)
into :index_name
do
begin
ddl = 'ALTER INDEX ' || index_name || ' ACTIVE;';
suspend;
end
/* get FOREIGN-KEY related indices */
for
select rdb$index_name from RDB$INDICES
where (rdb$index_inactive = 1) and (rdb$system_flag = 0 or rdb$system_flag is null) and (rdb$foreign_key is not null)
into :index_name
do
begin
ddl = 'ALTER INDEX ' || index_name || ' ACTIVE;';
suspend;
end
end
^^
SET TERM ; ^^


Use the SP with SELECT DDL FROM PRO_GETINDEXACTIVATESCRIPT;

Save the result set into a .sql file and execute it against
your database.



HTH,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database and MS SQL Server
Upscene Productions
http://www.upscene.com