Contributions
How to run a .sql file querys
Hi, I have a .sql file with many querys. This queries are written without following a standard format. I need a way to run this file without having to modify it. The only way I could was reading letter by letter and each query rewriting in a row. However this made the process very slow. What a way to run a file that contains formatting queries independent of them? Here is my code. function Auditoria(arquivoDiretorio: string): OleVariant; arquivoTxt := aqFile.OpenTextFile(arquivoDiretorio, aqFile.faRead, aqFile.ctANSI); quantidadeLinhas := arquivoTxt.LinesCount; //HERE I READ THE FILE . . . arrQuery := CreateVariantArray(0, quantidadeLinhas); posicaoArray := 0; while not arquivoTxt.IsEndOfFile() do begin //HERE I REWRITE ALL QUERYS OF FILE. . . . end; posicaoArray := posicaoArray - 1; VarArrayRedim(arrQuery, posicaoArray); //HERE ARE MY NEW QUERYS, EACH IN A LINE result := arrQuery; end; function AuditoriaBanco(strBanco: string, arrQuery: OleVariant): boolean; var strQtdErro, strCodErro, strQuery: string; oleQuery, oleConexao: OleVariant; intContador, totalLinhas: integer; begin result := true; oleConexao := FG_ConectaBanco(strBanco); totalLinhas := VarArrayHighBound(arrQuery, 1); for intContador := 0 to totalLinhas do begin strQuery := aqConvert.VarToStr(arrQuery[intContador]); if strQuery <> '' then begin try //HERE I EXECUTE THE QUERY oleQuery := oleConexao.Execute_(strQuery); except Log.Warning('Ocorreu o Erro: ' + '"' + exceptionmessage + '"' + ' Ao executar a query: ' + strQuery); end; if (intContador = totalLinhas) then begin oleQuery := oleConexao.Execute_(strQuery); oleQuery.MoveFirst; while not aqConvert.VarToBool(oleQuery.EOF) do begin strQtdErro := aqConvert.VarToStr(oleQuery.Fields('QTD_ERROS').Value); strCodErro := aqConvert.VarToStr(oleQuery.Fields('CODIGO').Value); if strQtdErro > 0 then begin Log.Warning('A auditoria ' + strCodErro + ' retornou ' + strQtdErro + ' erro(s).'); result := false; end; oleQuery.MoveNext; end; end; end; end; oleConexao.close; end;2.9KViews0likes3CommentsLog.Picture don't take the correct picture before Runner.Stop(true)
I have one event but the action Log.Picture don't take the correct picture on the screen. procedure GeneralEvents_OnLogError(Sender; LogParams); var autcom: OleVariant; begin Log.Picture(Sys.Desktop, '', '', pmHighest); autcom := Sys.Process('autcom'); if autcom.Exists then begin while autcom.Exists do begin try Sys.Process('autcom').Terminate; except Delay(1000); end; end; end; FB_LoginAutcom; Runner.Stop(true); end; If i change to procedure GeneralEvents_OnLogError(Sender; LogParams); var autcom: OleVariant; begin Log.Picture(Sys.Desktop, '', '', pmHighest); Runner.Stop(true); autcom := Sys.Process('autcom'); if autcom.Exists then begin while autcom.Exists do begin try Sys.Process('autcom').Terminate; except Delay(1000); end; end; end; FB_LoginAutcom; end; He takes the correct picture but stop the event on Runner.Stop If i dont use Log.Picture the TestComplete take own screen picture1.2KViews0likes1Comment