Hello !

What I understood looking at the sqlite3 sources is that an update is always 3 operations:

1- Read old row

2- Delete old row

3- Insert updated row

So I seems that using "insert" would be less work.

Cheers !


On 19/04/17 16:27, Simon Slavin wrote:
On 19 Apr 2017, at 7:47pm, no...@null.net wrote:

I use
triggers quite heavily as a kind of stored procedure.

Instead of basing them on views however I use real tables and AFTER
INSERT triggers whose final statement deletes the NEW row just
inserted.

I see two benefits to the use of AFTER INSERT triggers:

    * Constraints are enforced so SQLite catches invalid
    "procedure calls."
    * Default values for columns (or "arguments") can be defined. This
    is very useful if you want to use the incoming value in multiple
    statements - you don't have to hardcode a bunch of
    COALESCE(NEW.col, $DEFAULT) values everywhere.
Had you considered doing UPDATE instead of INSERT ?  Leave one row in the table 
and issue an UPDATE command when you want to trigger a trigger.  If the column 
you’re changing isn’t indexed it’s a little faster.  And just like INSERT you 
can use the value you set, using CASE … END, to set what you want to happen.

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

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

Reply via email to