title: sqlite how to update a column automatically from a variable
body: <p>I am trying to see if trigger is the function I can use for my situation. I basically want to imitate automatic update feature of Excel like how Sum(A:A) automatically updates and returns the sum. Here is my schema.</p>
  
  <pre><code>.schema
  CREATE TABLE product (id integer, name text, price integer);
  CREATE TABLE sum(total integer);
  </code></pre>
  
  <p>I want to trigger an INSERT/UPDATE command that sums price and inserts the value to total. I have tried the following but syntax error is giving me a headache.</p>
  
  <pre><code>CREATE TRIGGER strigger insert on product
  begin
  INSERT into sum(total) values(sum(price) from product);
  end;
  </code></pre>
  
  <p>Is this the right approach? or Do I have to deliberately call an update command from sqlite console or host language?
  Thanks for your help.</p>