Re: [sqlite] Simplify multiple use of value in a trigger

2017-01-10 Thread James K. Lowden
On Sat, 7 Jan 2017 17:54:20 -0500 Gan Uesli Starling wrote: > As for the suggestion to 'normalize' my four tables to one ... yes, I > could do that ... but it would make for a LOT of redundant data > duplicated in plural columns, which seems to me in my doubtless > ignorant newbie status, as m

Re: [sqlite] Simplify multiple use of value in a trigger

2017-01-08 Thread Simon Slavin
On 8 Jan 2017, at 12:46pm, Gan Uesli Starling wrote: > But it seems theres no way to make that a single, all-in-one-go kind of query. Are you aware of SELECT … JOIN … ? SELECT state.this,country.that FROM state JOIN country ON country.name = state.country WHERE state.name = "Wa

Re: [sqlite] Simplify multiple use of value in a trigger

2017-01-08 Thread Gan Uesli Starling
Okay, this trigger what works. Not really an answer, since there's no simplification achieved. Still thought I'd post it though, as a conclusion-of-sorts nonetheless. It's neither clever nor elegant, but it does work. Hammer and tongs, is what it is. There's no decision tree for choosing when

Re: [sqlite] Simplify multiple use of value in a trigger

2017-01-07 Thread Simon Slavin
On 7 Jan 2017, at 10:54pm, Gan Uesli Starling wrote: > As for the suggestion to 'normalize' my four tables to one ... yes, I could > do that ... but it would make for a LOT of redundant data duplicated in > plural columns, which seems to me in my doubtless ignorant newbie status, as > missin

Re: [sqlite] Simplify multiple use of value in a trigger

2017-01-07 Thread Gan Uesli Starling
Okay. Thank you everyone for the suggestions given thus far. I am SQLite version 3.15.2 if that's of import. Know all that the whole database project is on-line here: ky8d.net/sql As for the suggestion to 'normalize' my four tables to one ... yes, I could do that ... but it would make for a L

Re: [sqlite] Simplify multiple use of value in a trigger

2017-01-07 Thread R Smith
I'm not sure that CTE's are allowed inside triggers, but even so, it will need to be appended to each update. I think a real table (albeit a temporary one) will do much better - It should simply be a placeholder for variables, but has the benefit of being able to be joined to other queries, etc

Re: [sqlite] Simplify multiple use of value in a trigger

2017-01-07 Thread Simon Slavin
On 7 Jan 2017, at 2:27pm, Gan Uesli Starling wrote: > CREATE TRIGGER _160m_Increment > AFTER UPDATE ON qso WHEN >NEW.freq LIKE '1.%' > BEGIN >SELECT country AS c FROM qth WHERE rowid = NEW.qth_other_id; >SELECT state AS s FROM qth WHERE rowid = NEW.qth_other_id; >UPDATE usa_sta

Re: [sqlite] Simplify multiple use of value in a trigger

2017-01-07 Thread Doug Currie
On Sat, Jan 7, 2017 at 9:27 AM, Gan Uesli Starling wrote: > So I'm trying to accumulate data for state/prov inside of USA, Canada and > Mexico, and country for the rest of the world. > > Since country and state from the same update are factors in incrementing > each of four tables, > You should

Re: [sqlite] Simplify multiple use of value in a trigger

2017-01-07 Thread Kees Nuyt
On Sat, 7 Jan 2017 09:27:57 -0500, Gan Uesli Starling wrote: > So I'm trying to accumulate data for state/prov inside of USA, Canada > and Mexico, and country for the rest of the world. > > Since country and state from the same update are factors in incrementing > each of four tables, I was hop

[sqlite] Simplify multiple use of value in a trigger

2017-01-07 Thread Gan Uesli Starling
So I'm trying to accumulate data for state/prov inside of USA, Canada and Mexico, and country for the rest of the world. Since country and state from the same update are factors in incrementing each of four tables, I was hoping to simplify it with a single select with 'AS' and then re-use the