There are two different types of insert that need to happen into a table, one is where the rowid (EventNodeId) is part of the actual insert, the other it is excluded so that AUTOINCREMENT will fill it in. There is an insert triggers to set the audit fields on the table during the insert. The question is how to make the trigger work for both cases. Here is the table and the trigger:
CREATE TABLE EventNode( EventNodeId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, ObjectId VARCHAR(50) NOT NULL UNIQUE, Name VARCHAR(100) NOT NULL, SortName VARCHAR(100), IsActive INTEGER DEFAULT 1 NOT NULL, NodeType INTEGER NOT NULL, Deleted CHAR(1) DEFAULT 'N' NOT NULL, lft INTEGER NOT NULL, rgt INTEGER NOT NULL, insertedby VARCHAR(50) NOT NULL, instertedon TIMESTAMP NOT NULL, updatedby VARCHAR(50) NOT NULL, updatedon TIMESTAMP NOT NULL ); CREATE TRIGGER ti_EventNode_standard BEFORE INSERT ON EventNode BEGIN INSERT INTO EventNode ( EventNodeId, ObjectId, Name, IsActive, NodeType, lft, rgt, insertedby, instertedon, updatedby, updatedon) VALUES (new.EventNodeId, new.ObjectId, new.Name, new.IsActive, new.NodeType, new.lft, new.rgt, new.insertedby, julianday('now'), new.insertedby, julianday('now')); SELECT RAISE(IGNORE); END; _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users