Hello!

В сообщении от Tuesday 26 August 2008 16:44:56 Igor Tandetnik написал(а):
> > Can I group logged queries by any transaction id?
>
> Well, BEGIN TRANSACTION and END TRANSACTION are themselves queries, and
> thus will presumably appear in your log. Any queries in between would
> then belong to that transaction.

I don't know method to set triggers on begin and commit transaction events.

For example:

CREATE TABLE groups
(
  id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  save_date REAL,
  update_date REAL,
  delete_date REAL NOT NULL DEFAULT '',
  name TEXT COLLATE russian UNIQUE NOT NULL DEFAULT ''
);

create trigger groups_insert after insert on groups begin
  SELECT notify_insert('groups', NEW.rowid, NEW.id, NEW.save_date, 
NEW.update_date, NEW.delete_date, NEW.name);
  update groups set save_date = coalesce(save_date, 
julianday('now')),update_date = julianday('now') where rowid=NEW.rowid;
end;

create trigger groups_update_after after update on groups begin
  update groups set update_date = julianday('now') where rowid=OLD.rowid;
  SELECT notify_update('groups', NEW.rowid, NEW.id, NEW.save_date, 
NEW.update_date, NEW.delete_date, NEW.name);
end;

In my log I get lines as:

DATABASE NOTIFY UPDATE  table=groups   rowid=1003646
        1003646 2454528.5 2454704.97969 {group_name}
...

(and I'm saving log records to another SQLite database).

Best regards, Alexey.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to