How to migrate CacheUpdate with BDE

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mazoom
Posts: 2
Joined: Fri 01 Oct 2010 13:44

How to migrate CacheUpdate with BDE

Post by mazoom » Fri 01 Oct 2010 14:11

Hi,
i need to migrate from BDE to IBDAC and there are doubts about how to modify the cache update used.

Can I have an example of the use of cacheupdate with IbDac following the line of the example of my code to modify?

Thanks

---------------------------------------------
if (dm1.DBApp.InTransaction = TRUE) then dm1.DBApp.commit;
dm1.dbapp.StartTransaction;


Q_app2 := TQuery.Create(nil);
q_app2.DatabaseName := 'DBAppoggio';
q_app2.RequestLive := false;

q_app1 := tupdatesql.Create(nil);
Q_app := TQuery.Create(nil);
q_app.DatabaseName := 'DBAppoggio';
q_app.RequestLive := false;
q_app.CachedUpdates := true;
q_app.UpdateObject := q_app1;

try

q_app.sql.text := 'select * from parfar';
q_app.open;

q_app1.query[ukinsert].sql.Text := 'insert into lg_tot_termope (data,numero_settimana,anno_competenza_settimana,operatore,terminale,ora_inizio,ora_fine,vendite,clienti,lordo) ' +
'values (:data,:numero_settimana,:anno_competenza_settimana,:operatore,:terminale,:ora_inizio,:ora_fine,:vendite,:clienti,:lordo) ';

q_app1.query[ukinsert].prepare;

app := nomecomputer;

q_app2.close;
q_app2.sql.Text := 'select * from lg_totope order by data';
q_app2.open;
while not q_app2.eof do
begin


numero_settimana := weekof(q_app2.FieldByName('data').asdatetime);
anno_competenza_settimana := yearof(q_app2.fieldbyname('data').asdatetime);

//***********************************
//**Settimana dell' Anno Precedente**
//***********************************
if ((weekof(q_app2.FieldByName('data').asdatetime) = 53) or (weekof(q_app2.FieldByName('data').asdatetime) = 52)) and (monthof(q_app2.FieldByName('data').asdatetime) = 1) then
anno_competenza_settimana := anno_competenza_settimana - 1;
if ((weekof(q_app2.FieldByName('data').asdatetime) = 1) or (weekof(q_app2.FieldByName('data').asdatetime) = 2)) and (monthof(q_app2.FieldByName('data').asdatetime) = 12) then
anno_competenza_settimana := anno_competenza_settimana + 1;


q_app1.query[ukinsert].close;
q_app1.query[ukinsert].parambyname('data').asdatetime := q_app2.FieldByName('data').asdatetime;
q_app1.query[ukinsert].parambyname('numero_settimana').asinteger := numero_settimana;
q_app1.query[ukinsert].parambyname('anno_competenza_settimana').asinteger := anno_competenza_settimana;
q_app1.query[ukinsert].parambyname('operatore').asinteger := q_app2.FieldByName('codice_op').asinteger;
q_app1.query[ukinsert].parambyname('terminale').asstring := app;
q_app1.query[ukinsert].parambyname('ora_inizio').asstring := '08:00:00';
q_app1.query[ukinsert].parambyname('ora_fine').asstring := '20:00:00';
q_app1.query[ukinsert].parambyname('vendite').asinteger := q_app2.FieldByName('num_vendite').asinteger;
q_app1.query[ukinsert].parambyname('clienti').asinteger := q_app2.FieldByName('num_clienti').asinteger;
q_app1.query[ukinsert].parambyname('lordo').asfloat := q_app2.FieldByName('importo_lordo').asfloat;
q_app1.query[ukinsert].execsql;
q_app.ApplyUpdates;
q_app.CommitUpdates;

q_app2.Next;
end;


q_app1.query[ukmodify].SQL.text := 'insert into operazioni_tecniche (operazione,data) values (''OPERAZI256'',''TODAY'')';
q_app1.query[ukmodify].execsql;
q_app.ApplyUpdates;
q_app.CommitUpdates;

dm1.DBApp.commit;

logo.lblMsg.caption := 'Fine Operazione Tecnica 256 in Corso...';
logo.lblmsg.refresh;

except

q_app.close;
dm1.DBApp.Rollback;
application.MessageBox(pchar('Non sono riuscito ad effettuare l''operazione tecnica n. 256.'), 'Attenzione', MB_OK + MB_ICONERROR);

end;

q_app1.query[ukinsert].close;
q_app1.query[ukinsert].unprepare;
q_app1.free;

q_app.close;
q_app.free;

q_app2.close;
q_app2.free;

AndreyZ

Post by AndreyZ » Mon 04 Oct 2010 07:27

Hello,

Please, take a look at the CachedUpdates example in IBDACDemo. Also, in IBDACDemo you will find the TIBCQuery and TIBCUpdateSQL usage examples.

You can use the BDE/IBX Migration Wizard that allows you to convert your BDE or IBX projects to IBDAC. This wizard replaces BDE/IBX components at the specified project (dfm-and pas-files) to IBDAC. In the main menu of your IDE choose the InterBase menu and then choose BDE/IBX Migration Wizard. For more information please read the Migration Wizard topic of the IBDAC Reference Manual.

Post Reply