General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Transações não concluidas
Environment versions
Network:
Windows 2000 Server
Ola, estou utilizando o seguinte esquema de transação no sql server:
llGravacaoOK=.T.
If SQLExec(gnConnHandle,"begin transaction") < 0
Messagebox("Impossivel iniciar transação",48,"Atenção")
Return
Endif
Try
m.xparc = 0
Scan All
lcCmd="Insert into fatpag50 (filial_id,fatura_id,fornec_id,tipo,numero,valor,emissao,vencto,"+;
"historico,fluxo,datalan) values (?gcEmpresa,0,?view_pesquisafornecedores.fornec_id,"+;
"?tipodoc.tipo,?.txtnumero.Value,?cur_parc.valor,?.txtemissao.Value,?cur_parc.vencto,"+;
"?.txthistorico.Value,?.txtfluxo.Value,?Date())"
If SQLExec(gnConnHandle,lcCmd) < 0
Aerror(aErroSQL)
=Messagebox("Erro ao inserir registro no fatpag50 : "+aErroSQL(2),48,"Atenção")
llGravacaoOK=.F.
Endif
Select cur_parc
Endscan
Catch To oExcecao && Trata o erro
Messagebox("Houve um erro!"+Chr(13)+;
"Erro: "+Transform(oExcecao.ErrorNo)+Chr(13)+;
"Mensagem: "+oExcecao.Message+Chr(13)+Chr(13)+;
" : Operação sera revertida!!!!",0+16,"Ajuda")
llGravacaoOK=.F.
Endtry
If llGravacaoOK=.T.
Wait Window [Commit Transaction] Timeout .5
If SQLExec(gnConnHandle,"commit") < 0
Messagebox("Impossivel finalizar transação",48,"Atenção")
Return
Endif
Else
Wait Window [Rollback Transaction] Timeout .5
= SQLExec(gnConnHandle,"rollback")
Endif
***
Funciona tudo perfeitamente, o problema é que as tabelas envolvidas na transação sofrem um lock pelo banco até que seje enviado o commit ou o rollback finalizando a transação! até ai sem problemas o problema é quando cai a conexão as tabelas ficam travadas para outros usuarios! como posso tratar isso? pois hoje tenho que dar um stop e re-star no sql, pra liberar a conexoes e transações, nada inteligente, tem alguma comando pra enviar antes da transação avisao que se a conexao quebrar a transação dever ser revertida automaticamente???
Marcelo.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only