On Sat, Sep 18, 2004 at 04:58:53PM -0400, D. Richard Hipp wrote: > [EMAIL PROTECTED] wrote: > >I am working with triggers on a field defined in a table > >as INTEGER PRIMARY KEY. Agreed, triggers are not fully > >implemented on int primary key; but, I need the autoincrement > >feature. > > > >I always get -1. Can I depend on that -1 until this feature > >is implemented? > > > > If you specify the value of the INTEGER PRIMARY KEY, you > will always see that value in all triggers. If you put a > NULL into an INTEGER PRIMARY KEY, you'll always see a > -1 on BEFORE triggers but the true value on AFTER triggers. > The -1 appears on BEFORE triggers because at the time the > trigger fires, the actual rowid has not yet been computed. > > >-- > >-- Also create an insert log > >CREATE TRIGGER insert_log INSERT ON mesg > ^--- insert AFTER here > >BEGIN > >INSERT INTO log (mkey,mesgNEW,sqlType,mesgtimeEnter,timeEnter) > > values (new.mkey > > ,new.mesg,'INSERT',new.timeEnter,DATETIME('NOW') ); > >END; > > > > If you do not explicitly say "AFTER", it assumes a "BEFORE". > > > -- > D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565
Wonderful! Thank you. Mike Chirico