On 4/7/06, Jay Sprenkle <[EMAIL PROTECTED]> wrote: > On 4/7/06, Pam Greene <[EMAIL PROTECTED]> wrote: > > I use sqlite3_create_function() to attach C++ functions to SQLite > > triggers. For example, I create the SQL function INSERT_HANDLER(), > > bound to the C++ function InsertTriggerHandler(). Then I create a > > trigger: > > > > CREATE TRIGGER trig AFTER INSERT ON TableName > > FOR EACH ROW > > WHEN (INSERT_HANDLER(new.A, new.B) NOTNULL) > > BEGIN > > SELECT RAISE(FAIL, 'Error during insert trigger.'); > > END > > > > The trouble is, although the trigger persists indefinitely, the > > INSERT_HANDLER() function is only defined for as long as the database > > connection it was created with exists, and only when the INSERT that > > causes the trigger uses the same connection. > > > > Is there any way to create a more broadly available, persistent custom > > function, short of building it into sqlite? Or does anyone have > > another suggestion to solve the implicit problem? > > I don't think there is. What does your insert_handler() do?
Lots of things incompatible with doing it all in SQL, unfortunately. This is for a full-text indexing system, so the triggers split the text in a document column into words, optionally process (stem or case-normalize) them, and add them into parallel token tables along with some useful meta-information. (Analogous DELETE and UPDATE triggers keep everything properly in sync.) - Pam