[...]
>
> The ROWID is not generated until the INSERT statement actually runs.
> Hence the BEFORE trigger does not have access to it and the BEFORE
> trigger sees a NULL. Change the trigger to an AFTER trigger and it
> will work.
>
[...]
>
> D. Richard Hipp
> [email protected]
Thanks for the unbelievable fast response but
sorry: my code wasn't completely what I wanted so here again:
CREATE TRIGGER IF NOT EXISTS test
BEFORE INSERT ON "a"
BEGIN
INSERT INTO a(code,name,creator)
VALUES(new."code",new."name",new."identity");
SELECT RAISE(IGNORE);
END;
the difference is that I put new."identity" into the field "creator". This is
the way I chose to differ between creation and altering/updating of a record
(In case of an UPDATE I've another trigger that shoots new."identity" into
another field. The result is a kind of record-logging the "normal" user should
see.
On the other hand I've a complete logging that writes every
inserted/updated/deleted record in a special table. If I use a trigger in your
suggested way
CREATE TRIGGER IF NOT EXISTS test
AFTER INSERT ON "a"
BEGIN
INSERT INTO a(code,name,identity)
VALUES(new."code",new."name",new."identity");
UPDATE a SET creator = identity, identity = NULL;
END;
I'd get 2 entries per record in the log - I'd like to avoid this. Are there
other possibilities? Maybe I'm only a little balky? ;-)
______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users