On Tue, Jul 1, 2008 at 3:37 PM, Igor Tandetnik <[EMAIL PROTECTED]> wrote:
> They won't fail - they will successfully insert zero records. It's
> perfectly valid to run INSERT ... SELECT and have the SELECT part
> produce an empty resultset. It simply does nothing.
Sorry, I should have been more explicit in what we are doing.  The
select will return results because we do not want to delete the data
from the temporary table (that involves a write and fsyncing).
However, I think I've come up with a solution:
CREATE TRIGGER ....
BEGIN
  INSERT OR REPLACE INTO temp_table
  SELECT * FROM table_view
  WHERE <the data is currently not in temp table>
  AND <which record you want copied>;

  UPDATE temp_table SET ...;
END;

This works since the UNION will select entries from the temp table
first, and ignore those in the permanent table that have the same
primary key (that is, assuming I understand UNION properly).  I'm also
making the assumption that it is valid to query the view that the
trigger is running on.

Is this a sound approach?

Cheers,

Shawn
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to