Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppendSQLStatements - drop/create index exception in use [DNET972] #891

Closed
firebird-automations opened this issue Sep 29, 2020 · 0 comments

Comments

@firebird-automations
Copy link

Submitted by: Marcos R. Weimer (marcosweimer)

Delete a second index (unique desc) in the PK and create it again (desc). It is not the PK index, it is a secondary index in field.
Execute at IBExpert works perfectly.

Code:

ASQL = " SET TERM ^ ;
EXECUTE BLOCK AS
BEGIN
IF(EXISTS(SELECT 1
FROM RDB$INDICES
WHERE UPPER(RDB$INDEX_NAME) = 'PK_PARCEIROS_DESC')) THEN
BEGIN
EXECUTE STATEMENT 'DROP INDEX PK_PARCEIROS_DESC;';
EXECUTE STATEMENT 'CREATE DESCENDING INDEX PK_PARCEIROS_DESC ON PARCEIROS (PARCEIRO);';
END
END^
SET TERM ; ^"

FbScript sc = new FbScript(ASql);
sc.Parse();

FbBatchExecution fbe = new FbBatchExecution(FConexao);
fbe.AppendSqlStatements(sc);
fbe.Execute();

Exeption:

"An exception was thrown when executing command: -- Author: Thiago Cousseau\r\n-- 2589\r\n-- 24/07/2020\r\n-- Description: Já existe o indice da PK\r\nEXECUTE BLOCK AS\r\nBEGIN\r\n IF(EXISTS(SELECT 1\r\n FROM RDB$INDICES\r\n WHERE UPPER(RDB$INDEX_NAME) = 'PK_PARCEIROS_DESC')) THEN\r\n BEGIN\r\n EXECUTE STATEMENT ('DROP INDEX PK_PARCEIROS_DESC;') WITH AUTONOMOUS TRANSACTION;\r\n EXECUTE STATEMENT ('CREATE DESCENDING INDEX PK_PARCEIROS_DESC ON PARCEIROS (PARCEIRO);') WITH AUTONOMOUS TRANSACTION;\t \r\n END\r\nEND.\r\nBatch execution aborted.\r\nThe returned message was: unsuccessful metadata update\r\nobject INDEX \"PK_PARCEIROS_DESC\" is in use\r\nAt block line: 11, col: 7."

StackTrace:

em FirebirdSql.Data.Isql.FbBatchExecution.Execute(Boolean autoCommit)
em UltraBanco.Banco.ExecuteScript(String ASql) em C:\Ultra\CSharp\UltraBanco\UltraBanco.cs:linha 576
em UltraAtualizador.Funcoes.AtualizarSistema(DataRow LinhaAtual, Int32 UltimaVersaoBanco, List`1 executaveisBaixar, DataTable excecoes, String nomeArquivoZip, List`1 EMailEquipe, Boolean VerificarConexoesAtivas, Boolean& aAtualizarFirebird) em C:\Ultra\CSharp\UltraAtualizador\Funcoes.cs:linha 586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants