SQLite Forum

.selecttrace unknown and strange errors
I believe the problem is the line:


which doesn't prefix `C1_QTY_PRODUCED` with `NEW.` or `OLD.`.

Please don't take this the wrong way – this comes from many years of experience from the days when the best diagnostic you could hope for was "HOW?", "WHAT?" or "SORRY" – but from the few threads you've posted ostensibly about problems with `.selecttrace`, I think you need to try and develop your "inner debugger".

I've done very little with triggers, but after cutting-and-pasting your code, and confirming that I get the same error, I simply searched for `C1_QTY_PRODUCED` within the block of code. First check is that it _does_ appear, as typed, in the `CREATE TABLE` statement (so: not a simple typo).

Next, in trying to discover which reference SQLite was complaining about, it was fairly obvious (to me, after much general experience) that all _other_ references both to it and other columns in `C1` were preceded by `NEW.` or `OLD.`. Coupled with my basic knowledge of triggers, I tried adding `NEW.` to the above line and it "worked" (as the trigger threw up some messages).

I haven't followed the logic of the trigger to know whether it should be `OLD.` instead, but I'm _fairly_ certain that it should be one or the other.