I'm setting up a resource string to drop, recreate, and repopulate a table
to use as a type of default values for colors on the UI.  Essentially a
default set of priority levels and FG/BG colors associated with that
priority color.

The table schema is as such:

CREATE TABLE [ColorScheme](
    [ForegroundColor] BIGINT NOT NULL DEFAULT 0,
    [BackgroundColor] BIGINT NOT NULL DEFAULT 12632256,
    [PriorityText] CHAR NOT NULL);

I then insert a bunch of default values I want, looking like this:

insert into ColorScheme values

Essentially hard coding the default color when I display something on the
UI that is of priority level 0.

What my objective is, once I populate the initial set of data, I want to
block any and all attempts that my code COULD do to update this exact row
above.  So on any insert, delete, or update, if PriorityLevel=0, I want a
NOOP.  This row does not update, it does not get deleted, this row
essentially becomes bulletproof until I delete the table or trigger.  The
user is not informed of the inaction.

Since I'm never going to have a priority of -1, I decided to try a trigger
like this:

Create Trigger ColorSchemeInsert instead of insert on ColorScheme for each
row when NEW.PriorityLevel=0
delete from ColorScheme where PriorityLevel=-1;

However, SQLite Expert is throwing an error saying "cannot create INSTEAD
OF trigger on table: ColorScheme".

If I remove the INSTEAD OF statement, the trigger is created without error,
BUT, based on this ON CONFLICT REPLACE statement, the insert happens


(For now, I'm not going to worry about the trigger, but it is something I
want in)
sqlite-users mailing list

Reply via email to