dimanche 31 mai 2015

Sync two SQLite databases via a single sqlstatement?

I have two identical databases with parameters. From then on only the column "Value" can change. So there will be no delete or insert statements, just update commands on the column Value and column "lastChanged"

till now I have attached both databases via

attach database 'parameters.db' as parameters;
attach database 'parameters1.db' as parameters1;

no I have this command to determine the last changed value of both tables with

select 
CASE par.lastchange WHEN par.lastchange > par1.lastchange THEN
    par.wert
ELSE
    par1.wert
END as newvalue
from parameters.parameter par
left join parameters1.parameter par1
    on par.id=par1.id
where par.wert<>par1.wert

is there a way to wrap this command into a update command? or do I have to iterate through the result set and execute the update commands by my self inidivually?

Aucun commentaire:

Enregistrer un commentaire