Subject | Re: [IBO] Insert problem... |
---|---|
Author | Fabio Lobo |
Post date | 2002-01-18T16:24:59Z |
Luiz, thanks for help.
I moved 50000 records, delayed 18 minutes...
I ordered the routine to see if you can help me...
thank's a lot
Fabio Lobo
procedure UpdateEcon3v;
var vtime : tdatetime;
begin
if not ibDsqlEcon3v.Prepared then
ibDsqlEcon3v.Prepare;
tbEconv3.open;
Gauge1.MaxValue := tbEconv3.RecordCount;
Gauge1.MinValue := 0;
Gauge1.Progress := 0;
vtime := time;
label1.caption := 'Total de Registros: '+inttostr(tbEconv3.recordcount);
label2.caption := 'Inicio da movimentação: '+formatdatetime('hh:nn:ss',vtime);
tbEconv3.First;
ibtn.BeginBusy(True);
While not tbEconv3.Eof do
begin
// if (tbEconv3.fieldbyname('data').asdatetime >= dat_ini) and (tbEconv3.fieldbyname('data').asdatetime <= dat_fim) then
begin
ibDsqlEcon3v.parambyname('cartao').asInteger := tbEconv3.fieldbyname('cartao').asInteger;
ibDsqlEcon3v.parambyname('data').asDateTime := tbEconv3.fieldbyname('data').asDateTime;
ibDsqlEcon3v.parambyname('SeqGravacao').asInteger := Gauge1.Progress;
ibDsqlEcon3v.parambyname('entrada').asDateTime := tbEconv3.fieldbyname('entrada').asDateTime;
ibDsqlEcon3v.parambyname('saida').asDateTime := tbEconv3.fieldbyname('saida').asDateTime;
ibDsqlEcon3v.parambyname('empresa').asInteger := tbEconv3.fieldbyname('empresa').asInteger;
ibDsqlEcon3v.parambyname('filial').asInteger := tbEconv3.fieldbyname('filial').asInteger;
ibDsqlEcon3v.parambyname('ordem').asInteger := tbEconv3.fieldbyname('ordem').asInteger;
ibDsqlEcon3v.parambyname('mes').asInteger := tbEconv3.fieldbyname('mes').asInteger;
ibDsqlEcon3v.parambyname('ano').asInteger := tbEconv3.fieldbyname('ano').asInteger;
ibDsqlEcon3v.parambyname('irreg_entr').asInteger := tbEconv3.fieldbyname('irreg_entr').asInteger;
ibDsqlEcon3v.parambyname('irreg_saida').asInteger := tbEconv3.fieldbyname('irreg_saida').asInteger;
ibDsqlEcon3v.parambyname('irreg_outros').asInteger := tbEconv3.fieldbyname('irreg_outros').asInteger;
ibDsqlEcon3v.parambyname('horario').asInteger := tbEconv3.fieldbyname('horario').asInteger;
ibDsqlEcon3v.parambyname('codigo').asInteger := tbEconv3.fieldbyname('codigo').asInteger;
ibDsqlEcon3v.parambyname('entrada1').asDateTime := tbEconv3.fieldbyname('entrada1').asDateTime;
ibDsqlEcon3v.parambyname('entrada2').asDateTime := tbEconv3.fieldbyname('entrada2').asDateTime;
ibDsqlEcon3v.parambyname('almoco_1').asDateTime := tbEconv3.fieldbyname('almoco_1').asDateTime;
ibDsqlEcon3v.parambyname('almoco_4').asDateTime := tbEconv3.fieldbyname('almoco_4').asDateTime;
ibDsqlEcon3v.parambyname('saida_1').asDateTime := tbEconv3.fieldbyname('saida_1').asDateTime;
ibDsqlEcon3v.parambyname('saida_2').asDateTime := tbEconv3.fieldbyname('saida_2').asDateTime;
ibDsqlEcon3v.parambyname('efer').asString := tbEconv3.fieldbyname('efer').asString;
ibDsqlEcon3v.parambyname('efolga').asString := tbEconv3.fieldbyname('efolga').asString;
ibDsqlEcon3v.parambyname('vira_noite').asString := tbEconv3.fieldbyname('vira_noite').asString;
ibDsqlEcon3v.parambyname('cod_cc').asString := tbEconv3.fieldbyname('cod_cc').asString;
ibDsqlEcon3v.parambyname('depto').asString := tbEconv3.fieldbyname('depto').asString;
ibDsqlEcon3v.ExecSQL;
end;
tbEconv3.Next;
Gauge1.Progress := Gauge1.Progress + 1;
if (Gauge1.progress mod 1000)=0 then
begin
ibtn.commitretaining; //commit each 1000 records
application.processmessages;
end;
end;
label3.caption := 'Fim da movimentação: '+formatdatetime('hh:nn:ss',vtime)+' tempo: '+formatdatetime('hh:nn:ss',time-vtime);
try
if ibtn.started then
ibtn.commit;
except
Showmessage('Problemas na Gravação...');
ibtn.rollback;
end;
ibtn.EndBusy;
label4.caption := 'Fim da transação: '+formatdatetime('hh:nn:ss',vtime)+' tempo: '+formatdatetime('hh:nn:ss',time-vtime);
end;
I moved 50000 records, delayed 18 minutes...
I ordered the routine to see if you can help me...
thank's a lot
Fabio Lobo
procedure UpdateEcon3v;
var vtime : tdatetime;
begin
if not ibDsqlEcon3v.Prepared then
ibDsqlEcon3v.Prepare;
tbEconv3.open;
Gauge1.MaxValue := tbEconv3.RecordCount;
Gauge1.MinValue := 0;
Gauge1.Progress := 0;
vtime := time;
label1.caption := 'Total de Registros: '+inttostr(tbEconv3.recordcount);
label2.caption := 'Inicio da movimentação: '+formatdatetime('hh:nn:ss',vtime);
tbEconv3.First;
ibtn.BeginBusy(True);
While not tbEconv3.Eof do
begin
// if (tbEconv3.fieldbyname('data').asdatetime >= dat_ini) and (tbEconv3.fieldbyname('data').asdatetime <= dat_fim) then
begin
ibDsqlEcon3v.parambyname('cartao').asInteger := tbEconv3.fieldbyname('cartao').asInteger;
ibDsqlEcon3v.parambyname('data').asDateTime := tbEconv3.fieldbyname('data').asDateTime;
ibDsqlEcon3v.parambyname('SeqGravacao').asInteger := Gauge1.Progress;
ibDsqlEcon3v.parambyname('entrada').asDateTime := tbEconv3.fieldbyname('entrada').asDateTime;
ibDsqlEcon3v.parambyname('saida').asDateTime := tbEconv3.fieldbyname('saida').asDateTime;
ibDsqlEcon3v.parambyname('empresa').asInteger := tbEconv3.fieldbyname('empresa').asInteger;
ibDsqlEcon3v.parambyname('filial').asInteger := tbEconv3.fieldbyname('filial').asInteger;
ibDsqlEcon3v.parambyname('ordem').asInteger := tbEconv3.fieldbyname('ordem').asInteger;
ibDsqlEcon3v.parambyname('mes').asInteger := tbEconv3.fieldbyname('mes').asInteger;
ibDsqlEcon3v.parambyname('ano').asInteger := tbEconv3.fieldbyname('ano').asInteger;
ibDsqlEcon3v.parambyname('irreg_entr').asInteger := tbEconv3.fieldbyname('irreg_entr').asInteger;
ibDsqlEcon3v.parambyname('irreg_saida').asInteger := tbEconv3.fieldbyname('irreg_saida').asInteger;
ibDsqlEcon3v.parambyname('irreg_outros').asInteger := tbEconv3.fieldbyname('irreg_outros').asInteger;
ibDsqlEcon3v.parambyname('horario').asInteger := tbEconv3.fieldbyname('horario').asInteger;
ibDsqlEcon3v.parambyname('codigo').asInteger := tbEconv3.fieldbyname('codigo').asInteger;
ibDsqlEcon3v.parambyname('entrada1').asDateTime := tbEconv3.fieldbyname('entrada1').asDateTime;
ibDsqlEcon3v.parambyname('entrada2').asDateTime := tbEconv3.fieldbyname('entrada2').asDateTime;
ibDsqlEcon3v.parambyname('almoco_1').asDateTime := tbEconv3.fieldbyname('almoco_1').asDateTime;
ibDsqlEcon3v.parambyname('almoco_4').asDateTime := tbEconv3.fieldbyname('almoco_4').asDateTime;
ibDsqlEcon3v.parambyname('saida_1').asDateTime := tbEconv3.fieldbyname('saida_1').asDateTime;
ibDsqlEcon3v.parambyname('saida_2').asDateTime := tbEconv3.fieldbyname('saida_2').asDateTime;
ibDsqlEcon3v.parambyname('efer').asString := tbEconv3.fieldbyname('efer').asString;
ibDsqlEcon3v.parambyname('efolga').asString := tbEconv3.fieldbyname('efolga').asString;
ibDsqlEcon3v.parambyname('vira_noite').asString := tbEconv3.fieldbyname('vira_noite').asString;
ibDsqlEcon3v.parambyname('cod_cc').asString := tbEconv3.fieldbyname('cod_cc').asString;
ibDsqlEcon3v.parambyname('depto').asString := tbEconv3.fieldbyname('depto').asString;
ibDsqlEcon3v.ExecSQL;
end;
tbEconv3.Next;
Gauge1.Progress := Gauge1.Progress + 1;
if (Gauge1.progress mod 1000)=0 then
begin
ibtn.commitretaining; //commit each 1000 records
application.processmessages;
end;
end;
label3.caption := 'Fim da movimentação: '+formatdatetime('hh:nn:ss',vtime)+' tempo: '+formatdatetime('hh:nn:ss',time-vtime);
try
if ibtn.started then
ibtn.commit;
except
Showmessage('Problemas na Gravação...');
ibtn.rollback;
end;
ibtn.EndBusy;
label4.caption := 'Fim da transação: '+formatdatetime('hh:nn:ss',vtime)+' tempo: '+formatdatetime('hh:nn:ss',time-vtime);
end;
----- Original Message -----
From: Luiz Alves
To: IBObjects@yahoogroups.com
Sent: Wednesday, January 16, 2002 6:58 PM
Subject: Re: [IBO] Insert problem...
Fabio,
> I am initiating to use interbase and ibobjects, and necessary of aid with
problems with inserts, I have a routine that reads the records, treats and
save in another archive using paradox, with paradox the performance is very
bigger greater than interbase, I already tried to use cache updates in
query, start transaction, but the performance continues slow, and this
process has that to be twirled daily with more than 100.000 registers...
please they help me...
Try use a tib_cursor to loop into records, use static references to fields,
use BeginBusy/EndBusy and don't use bound controls to datasource of dataset.
Sample:
procedure update_file;
var nc,np,id,k,MAXCLI:Integer;
s:string;
totrep,totcli:Longint;
tb_ativ,tb_nome,tb_ender,tb_bairro,
tb_cidade,tb_est,tb_cep,tb_nasc,tb_sexo,
tb_cor,tb_ecivil,tb_matr,tb_alt,tb_peso,tb_nac,
tb_cargo,tb_telres,tb_teltra,tb_ramtra,
tb_admi,tb_titular,tb_natu,tb_ident,tb_oemis,
tb_nconv,tb_nplano,tb_ident_cp,tb_empresa,
tb_QUEM_ALT,tb_NINDICA,tb_CPF,tb_DATAVAL,tb_OBS,
tb_PRODUTO,tb_DEPENDENTE,tb_DATAPAG,tb_DATACAD:Tib_column;
begin
with cu_clif do begin
if not prepared then prepare;
tb_ativ:=parambyname('ATIVO');
tb_nome:=parambyname('NOME');
tb_ender:= parambyname('ENDER');
tb_bairro:= parambyname('BAIRRO');
tb_cidade:= parambyname('CIDADE');
tb_est:=parambyname('ESTADO');
tb_cep:=parambyname('CEP');
tb_nasc:= parambyname('NASC');
tb_sexo:=parambyname('sexo');
tb_cor:=parambyname('cor');
tb_ecivil:= parambyname('ecivil');
tb_matr:= parambyname('matr');
tb_alt:= parambyname('ALTURA');
tb_peso:= parambyname('PESO');
tb_nac:= parambyname('NAC');
tb_cargo:= parambyname('CARGO');
tb_telres:= parambyname('TELRES');
tb_teltra:= parambyname('TELTRA');
tb_ramtra:= parambyname('RAMTRA');
tb_admi:= parambyname('ADMI');
tb_titular:= parambyname('TITULAR');
tb_natu:= parambyname('NATU');
tb_ident:= parambyname('IDENT');
tb_oemis:= parambyname('OEMIS');
tb_nconv:= parambyname('NCONV');
tb_nplano:= parambyname('NPLANO');
tb_ident_cp:= parambyname('IDENT_CP');
tb_empresa:= parambyname('EMPRESA');
tb_QUEM_ALT:= parambyname('QUEM_ALT');
tb_NINDICA:= parambyname('NINDICA');
tb_CPF:= parambyname('CPF');
tb_DATAVAL:= parambyname('DATAVAL');
tb_PRODUTO:= parambyname('PRODUTO');
tb_DEPENDENTE:= parambyname('DEPENDENTE');
tb_DATAPAG:= parambyname('DATAPAG');
tb_DATACAD:= parambyname('DATACAD');
tb_OBS:=parambyname('OBS');
end;
k:=0;
tcli.open;
clirep.open;
tcli.first;
tn.BeginBusy(True);
while not tcli.eof do begin
with cu_clif do begin
tb_ativ.asString:='T';
tb_nome.asString:=tcliNOME.asString;
tb_ender.asString:=tcliEndereo.asString;
tb_bairro.asString:=tclibairro.asString;
tb_cidade.asString:=tcliCIDADE.asString;
if checa_estado(tcliESTADO.asString) then
tb_est.asString:=tcliESTADO.asString
else tb_est.clear;
tb_cep.asString:=tcliCEP.asString;
tb_nasc.asDatetime:=tcliANIVERSRI.asDatetime;
s:='F';
tb_sexo.asString:=s;
tb_cor.asString:='B';
tb_ecivil.asString:='S';
tb_matr.Clear;
tb_alt.asfloat:=0;
tb_PESO.asfloat:=0;
tb_NAC.asString:='Brasileira';
tb_CARGO.Clear;
tb_TELRES.Clear;
tb_TELTRA.Clear;
tb_RAMTRA.Clear;
tb_ADMI.Clear;
tb_TITULAR.Clear;
tb_NATU.asString:=tcliCIDADE.asString;
tb_IDENT.Clear;
tb_OEMIS.asString:='I.F.P';
{tb_NCONV.asInteger:=1;
tb_NPLANO.asInteger:=0;
tb_IDENT_CP.asInteger:=13;}
tb_NCONV.Clear;
tb_NPLANO.Clear;
tb_IDENT_CP.Clear;
tb_EMPRESA.clear;
tb_QUEM_ALT.Clear;
tb_NINDICA.Clear;
tb_CPF.Clear;
tb_DATAVAL.Clear;
tb_PRODUTO.Clear;
tb_DEPENDENTE.Clear;
tb_DATAPAG.Clear;
tb_DATACAD.asDatetime:=trunc(now);
tb_OBS.Clear;
ExecSql; //I am using a tib_dsql to insert
end;
tcli.next;
inc(k);
if ((k>1000) and ((k mod 1000)=0)) then
tn.commitretaining; //commit each 1000 records
application.processmessages;
end;
try
if tn.started then
tn.commit;
except
raise;
tn.rollback;
end;
tn.EndBusy;
end;
Luiz.
Yahoo! Groups Sponsor
ADVERTISEMENT
___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]