Analizando rapidamente seu codigo deu para ver alguns detalhes, por exemplo:

>>dm.sqlGeral.SQL.Add('select max(CODIGO) as COD from TLISTA');

aqui vc poderia usar um generator, acho q ficaria mais rapido

SELECT GEN_ID(CHAVE_TLISTA,1) AS COD FROM RDB$DATABASES

> dm.sqlGeral.SQL.Add('UPDATE TLISTA SET  REGISTROS=');
> dm.sqlGeral.SQL.Add(QuotedStr(inttostr(total)));
> dm.sqlGeral.SQL.Add('where CODIGO='+QuotedStr(inttostr(lista)));

Eu nao sei qual componente de conexao vc esta usando, mas acho q ficaria
melhor assim:

dm.sqlGeral.SQL.Add('UPDATE TLISTA SET  REGISTROS= :REGISTROS');
dm.sqlGeral.SQL.Add('where CODIGO=:CODIGO');
dm.sqlGeral.SQL.ParamByName('REGISTROS').AsInteger:= Total;
dm.sqlGeral.SQL.ParamByName('CODIGO').AsInteger     :=Lista;

O correto tambem e q a cada 500 registros inseridos dar um commit ..

ate mais..


----- Original Message ----- 
From: "aldinei simoes" <[EMAIL PROTECTED]>
To: <delphi-br@yahoogrupos.com.br>
Sent: Tuesday, May 24, 2005 12:29 PM
Subject: Re: [delphi-br] Re: uso da CPU 100%


> Minha rotina é esta abaixo , exitem algumas variaveis
> que não são mais usadas
>
> var f : textfile;
>
> S,ser,dt,vend,tipo_erro,campos,valores,par,vr,vrpar,cps:
> string;
>
> total,cont,it,contr,dig,fi,cli,cli1,log,i,contem,tel1
> : integer;
>     erro_lista, erro_log : integer;
>     erro : boolean;
>     erros : Tstringlist;
> begin
>   erros := TStringList.Create;
>   erro_lista := 0;
>   erro_log := 0;
>   assignfile(f,edit1.Text);
>   reset(f);
>   readln(f);
>   while not eof(f) do
>     begin
>       inc(total);
>       readln(f);
>     end;
>   cps :=
> '(COD_CLIENTE,DIAS_PROX_AGEND,DD_IND,ORIGEM_CAD';
>   sgsel.RowCount := sgsel.RowCount-1;
>   fi := 0;
>   for it := 1 to sgsel.RowCount-1 do begin
>     cps := cps+','+trim(sgsel.Cells[0,it]);
>   end;
>   if rbnova.Checked then begin
>     dm.sqlGeral.Close;
>     dm.sqlGeral.sql.Clear;
>     dm.sqlGeral.SQL.Add('select max(CODIGO) as COD
> from TLISTA');
>     dm.sqlGeral.Prepared := true;
>     dm.sqlGeral.Open;
>     lista := 1;
>     if dm.sqlGeral.FieldValues['COD'] > 0 then
>       lista := dm.sqlGeral.FieldValues['COD']+1;
>     dt :=
> copy(datetostr(date),1,2)+'.'+copy(datetostr(date),4,2)+'.'+
>             copy(datetostr(date),7,4);
>     dm.sqlGeral.Close;
>     dm.sqlGeral.sql.Clear;
>     dm.sqlGeral.SQL.Add('INSERT INTO TLISTA
> (CODIGO,DESCRICAO,DATA_INICIO,'+
>
> 'REGISTROS,POSICAO,CAMPANHA)');
>     dm.sqlGeral.SQL.Add('VALUES
> ('+QuotedStr(inttostr(lista))+',');
>
> dm.sqlGeral.SQL.Add(QuotedStr(elista.text)+','+QuotedStr(dt)+',');
>
> dm.sqlGeral.SQL.Add(QuotedStr(inttostr(total))+',');
>     dm.sqlGeral.SQL.Add(QuotedStr('A')+',');
>
> dm.sqlGeral.SQL.Add(QuotedStr(lcbcampanha.KeyValue)+')');
>     dm.sqlGeral.ExecSQL;
>   end else begin
>     lista := dm.tblistaCODIGO.Value;
>     dm.sqlGeral.Close;
>     dm.sqlGeral.sql.Clear;
>     dm.sqlGeral.SQL.Add('UPDATE TLISTA SET
> REGISTROS=');
>     dm.sqlGeral.SQL.Add(QuotedStr(inttostr(total)));
>     dm.sqlGeral.SQL.Add('where
> CODIGO='+QuotedStr(inttostr(lista)));
>     dm.sqlGeral.ExecSQL;
>   end;
>   closefile(f);
>   gauge1.Progress := 0;
>   reset(f);
>   readln(f,s);
>   contr := 0;
>   while not eof(f) do begin
>     inc(contr);
>     campos := cps;
>     valores := '';
>     inc(log);
>     readln(f,s);
>     inc(cont);
>     label3.Repaint;
>     Gauge1.Progress := round(cont/total*100);
>     Gauge1.Repaint;
>     it := length(s);
>     ser := '';
>     fi := 1;
>     for dig := 1 to it do begin
>       if copy(s,dig,1) = ';' then begin
>         contem := strtoint(sgsel.Cells[1,fi]);
>         if contem > 0 then begin
>           ser := copy(ser,1,contem);
>         end;
>         if copy(s,dig-1,1) = ';' then
>           valores := valores+','+QuotedStr('0')
>         else
>           valores := valores+','+QuotedStr(ser);
>         ser := '';
>         inc(fi);
>       end else
>         ser := ser + copy(s,dig,1);
>     end;
>     if copy(s,dig-1,1) = ';' then begin
>       valores := valores+','+QuotedStr('0');
>     end else begin
>       valores := valores+','+QuotedStr(ser);
>     end;
>     try
>       campos := campos+',SITUACAO)';
>       valores :=
> '('+QuotedStr('0')+','+QuotedStr(inttostr(lista))+','+
>
> QuotedStr(lcbcampanha.KeyValue)+','+QuotedStr(edit3.Text)+
>                  valores+','+QuotedStr('A')+')';
>       dm.sqlGeral.Close;
>       dm.sqlGeral.sql.Clear;
>       dm.sqlGeral.SQL.Add('INSERT INTO TLOG_IMPORT
> '+campos+' VALUES '+valores);
>       dm.sqlGeral.ExecSQL;
>     except
>       On E: Exception do Begin
>         erros.Add(Pchar(Format('Erro log : '  + #13+
> 'Msg: %s' + #13 +
>                         'Classe: %s',[E.Message,
> E.ClassName])));
>         erros.Add(campos);
>         erros.Add(valores);
>         inc(erro_log);
>       end;
>     end;
>     if contr = 250 then begin
>       F_import.Repaint;
>       sleep(5000);
>       contr := 0;
>     end;
>   end;
>   closefile(f);
>   erros.Add('Erros no log '+inttostr(erro_log));
>   erros.SaveToFile('erros.txt');
>   erros.Free;
>   dm.SP_IMPORTA.ExecProc;
>
> --- Demian Lessa <[EMAIL PROTECTED]> escreveu:
> > Sim, mostre pra gente sua rotina de leitura e
> > processamento do arquivo.
> >
> > Cordialmente,
> >
> > Demian Lessa
> > Salvador - Brasil
> >
> > Aldinei Simoes wrote:
> > > Percebi que o problema esta na leitura do arquivo
> > texto e não na base,
> > > tem algo que eu possa fazer?
> > >
> > > Aldinei
> > >
> > >
> > >
> > >
> >
> >
> > -- 
> > <<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA
> > MENSAGEM >>>>>
> >
> > Para ver as mensagens antigas, acesse:
> >  http://br.groups.yahoo.com/group/delphi-br/messages
> >
> > Para falar com o moderador, envie um e-mail para:
> >  [EMAIL PROTECTED] ou
> > [EMAIL PROTECTED]
> >
> > Links do Yahoo! Grupos
> >
> >
> >
> >     http://br.yahoo.com/info/utos.html
> >
> >
> >
> >
> >
>
>
>
>
>
> ____________________________________________________
> Yahoo! Mail, cada vez melhor: agora com 1GB de espaço grátis!
http://mail.yahoo.com.br
>
>
> -- 
> <<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>
>
> Para ver as mensagens antigas, acesse:
>  http://br.groups.yahoo.com/group/delphi-br/messages
>
> Para falar com o moderador, envie um e-mail para:
>  [EMAIL PROTECTED] ou [EMAIL PROTECTED]
>
> Links do Yahoo! Grupos
>
>
>
>
>
>
>
>



-- 
<<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>

Para ver as mensagens antigas, acesse:
 http://br.groups.yahoo.com/group/delphi-br/messages

Para falar com o moderador, envie um e-mail para:
 [EMAIL PROTECTED] ou [EMAIL PROTECTED]
 
Links do Yahoo! Grupos

<*> Para visitar o site do seu grupo na web, acesse:
    http://br.groups.yahoo.com/group/delphi-br/

<*> Para sair deste grupo, envie um e-mail para:
    [EMAIL PROTECTED]

<*> O uso que você faz do Yahoo! Grupos está sujeito aos:
    http://br.yahoo.com/info/utos.html

 


Responder a