SET TERM ^ ;
EXECUTE BLOCK AS BEGIN
if (exists(select 1 from RDB$INDICES where RDB$INDEX_NAME='IDX_WGHCONTOSTO1_CONTAB2')) then 
execute statement 'drop INDEX IDX_WGHCONTOSTO1_CONTAB2;';
END^
EXECUTE BLOCK AS BEGIN
if (exists(select 1 from RDB$INDICES where RDB$INDEX_NAME='IDX_WGHCONTOSTO1_CONTAB')) then 
execute statement 'drop INDEX IDX_WGHCONTOSTO1_CONTAB;';
END^
EXECUTE BLOCK AS BEGIN
if (exists(select 1 from RDB$INDICES where RDB$INDEX_NAME='IDX_CODCONTO_CONTAB')) then 
execute statement 'drop INDEX IDX_CODCONTO_CONTAB;';
END^
EXECUTE BLOCK AS BEGIN
if (exists(select 1 from RDB$INDICES where RDB$INDEX_NAME='IDX_WGHALIQ1')) then 
execute statement 'drop INDEX IDX_WGHALIQ1;';
END^

COMMIT^
SET TERM ; ^
CREATE INDEX IDX_CODCONTO_CONTAB ON WGHADDSTO
  (CODCONTO);
  CREATE INDEX IDX_WGHCONTOSTO1_CONTAB ON WGHCONTOSTO
  (CAPOCONTO);
CREATE INDEX IDX_WGHCONTOSTO1_CONTAB2 ON WGHCONTOSTO
  (SOTTOCONTO);
  CREATE INDEX IDX_WGHALIQ1 ON WGHALIQ
  (INDICE);
