Re: [sqlite] Mimic MERGE in a trigger

2014-02-07 Thread Constantine Yannakopoulos
On Fri, Feb 7, 2014 at 2:50 PM, Constantine Yannakopoulos < alfasud...@gmail.com> wrote: > As for scaled integers for amounts, if it was up to me I would prefer BCDs > but this choice is out of my hands. Oh, also the "cube" table can contain records for many accumulators (e.g. debit, credit,

Re: [sqlite] Mimic MERGE in a trigger

2014-02-07 Thread Constantine Yannakopoulos
On Fri, Feb 7, 2014 at 2:10 PM, Simon Slavin wrote: > You're right. Let's see if I can make it up to you. I do think you came > up with the right strategy, and that doing INSERT OR IGNORE is going to > give you the best result overall. > Thanks. I myself couldn't come up

Re: [sqlite] Mimic MERGE in a trigger

2014-02-07 Thread Simon Slavin
On 7 Feb 2014, at 11:32am, Constantine Yannakopoulos wrote: > On Fri, Feb 7, 2014 at 1:27 PM, Simon Slavin wrote: > >> Don't do it like that. >> >> Use 'INSERT OR IGNORE' to insert a record with a zero amount. >> Then update the record which, now,

Re: [sqlite] Mimic MERGE in a trigger

2014-02-07 Thread Constantine Yannakopoulos
On Fri, Feb 7, 2014 at 1:27 PM, Simon Slavin wrote: > Don't do it like that. > > Use 'INSERT OR IGNORE' to insert a record with a zero amount. > Then update the record which, now, definitely does exist. > Obviously you didn't read all of my message. :)

Re: [sqlite] Mimic MERGE in a trigger

2014-02-07 Thread Simon Slavin
On 7 Feb 2014, at 11:03am, Constantine Yannakopoulos wrote: > I would like to create a trigger on table CustomerTrans that performs the > accumulation of transaction amounts in CustomerAccum. This trigger should > - Insert a record with the transaction amount if a record

[sqlite] Mimic MERGE in a trigger

2014-02-07 Thread Constantine Yannakopoulos
Hello everyone, Given a master table, a table of transactions and a table of cumulative amounts per transaction master: CREATE TABLE Customer ( id INTEGER PRIMARY KEY, firstname VARCHAR(50), lastname VARCHAR(50) ); CREATE TABLE CustomerTrans ( id INTEGER PRIMARY KEY, transactiondate