[firebase-br] Log em uma tabela diferente

Marcos Weimer marcosweimer em gmail.com
Qui Dez 22 11:46:47 -03 2016


sobre autonomous/common transaction..
http://firebirdsql.org/refdocs/langrefupd25-psql-execstat.html

Description: Traditionally, the executed SQL statement always ran within
the current transaction, and this is still the default. WITH AUTONOMOUS
TRANSACTION causes a separate transaction to be started, with the same
parameters as the current transaction. It will be committed if the
statement runs to completion without errors and rolled back otherwise. WITH
COMMON TRANSACTION uses the current transaction if possible. If the
statement must run in a separate connection, an already started transaction
within that connection is used, if available. Otherwise, a new transaction
is started with the same parameters as the current transaction. Any new
transactions started under the “COMMON” regime are committed or rolled back
with the current transaction.

uso autonomous para não influenciar na transaction atual.

-=Ma®©oS=-
Marcos R. Weimer
Delphi / C# / ASP.NET / PHP / WebServices / Firebird


Em 22 de dezembro de 2016 11:31, Firebase <firebase em dominioinf.com.br>
escreveu:

> Estou Tirando fora essa instrução
> WITH AUTONOMOUS
> TRANSACTION;
>
> Também desativei o ForcedWrites conforme dica do Carlos Cantu.
>
> Vamos ver se melhora.
>
> Grato
>
>
>
> -----Mensagem Original----- From: Marcos Weimer
> Sent: Thursday, December 22, 2016 10:05 AM
> To: FireBase
> Subject: Re: [firebase-br] Log em uma tabela diferente
>
> Aqui uso a mesma trigger para tudo (insert/update/delete), chamo uma
> procedure que fica responsável por gravar (em tabelas com muitos campos
> isso é essencial para a trigger não exceder o tamanho maximo permitido (não
> lembor qual é o tamanho agora, mas sei que fiz por procedure pq aconteceu
> de exceder o tamanho, e vendo depois, ficou até mais facil de entender))
>
> mesma trigger no after insert/update/delete
>
> if (Inserting) then
>  if (new.AFINIDADE is not null) then execute procedure
> log_gravar_coluna(:var_id, 'AFINIDADE', null, new.AFINIDADE );
> else if (Updating) then
>  if (old.AFINIDADE <> new.AFINIDADE) then execute procedure
> log_gravar_coluna(:var_id, 'AFINIDADE', old.AFINIDADE, new.AFINIDADE );
> else if (Deleting) then
>  if (old.AFINIDADE is not null) then execute procedure
> log_gravar_coluna(:var_id, 'AFINIDADE', old.AFINIDADE, null);
>
>
> ddl da procedure que grava coluna.....
>
> create or alter procedure LOG_GRAVAR_COLUNA (
>    OPERACAO_ID integer,
>    NOME_COLUNA varchar(31),
>    OLD_VALUE varchar(5000),
>    NEW_VALUE varchar(5000))
> as
> begin
>      execute statement (
>      'INSERT INTO log_campos (ID, OPERACAO_ID, COLUNA, VALOR_ANTERIOR,
> VALOR_NOVO)
>      VALUES (GEN_ID(GEN_LOG_CAMPOS, 1), ?, ?, ?, ?);')
>      (:OPERACAO_ID, :NOME_COLUNA, :OLD_VALUE, :NEW_VALUE)
>   WITH AUTONOMOUS TRANSACTION
>   AS USER 'SYSDBA'
>   PASSWORD 'masterkey'
>   ROLE 3
>  on external '127.0.0.1:caminhodobanco';
> end^
>
> SET TERM ; ^
>
>
>
> -=Ma®©oS=-
> Marcos R. Weimer
> Delphi / C# / ASP.NET / PHP / WebServices / Firebird
> ______________________________________________
> FireBase-BR (www.firebase.com.br) - Hospedado em www.locador.com.br
> Para saber como gerenciar/excluir seu cadastro na lista, use:
> http://www.firebase.com.br/fb/artigo.php?id=1107
> Para consultar mensagens antigas: http://www.firebase.com.br/pes
> quisa_lista.html
>
> ---
> Este email foi escaneado pelo Avast antivírus.
> https://www.avast.com/antivirus
>
>
> ______________________________________________
> FireBase-BR (www.firebase.com.br) - Hospedado em www.locador.com.br
> Para saber como gerenciar/excluir seu cadastro na lista, use:
> http://www.firebase.com.br/fb/artigo.php?id=1107
> Para consultar mensagens antigas: http://www.firebase.com.br/pes
> quisa_lista.html
>



Mais detalhes sobre a lista de discussão lista