:: insert-trigger ( table column foreign-table foreign-column -- sql ) [ "CREATE TRIGGER " % table foreign-table fki_bar_foo_id " BEFORE INSERT ON " % table % " FOR EACH ROW BEGIN" % " SELECT RAISE(ROLLBACK, 'insert on table \"" % table % "\" violates foreign key constraint " % foreign-table fk_foo_id " WHERE (SELECT " % column % " FROM " % table % " WHERE " % column % " = NEW." % foreign-column % ") IS NULL; END;" % ] "" make ;