On 10 Nov 2013, at 3:05pm, Igor Tandetnik <i...@tandetnik.org> wrote:

> That rather depends on what value you deem to be the correct one. You've 
> never explained the desired outcome of all this choreography.

He's trying to keep each player's rank in his league table.  And he wants the 
rank column for all players to be updated each time he inserts a new player in 
the table, so if he inserts a new player who is fourth, all players that were 
fourth or after fourth move down one rank.

Once again I suggest using a TRIGGER is the wrong way to do it:

A) You have to write a trigger for when a player joins a league.
B) You have to write an equivalent trigger for when a player leaves a league.
C) You have to write an equivalent trigger for when a player moves position.
D) That's a lot of checking and operations any time any player does anything.

Instead I think it makes more sense just to deduce the ranks from the results 
of your SELECT, when you select the players in points order.  The player who 
comes off first is ranked 1.  Not only is it simple but it requires no extra 
operations, so it speeds up all INSERT/UPDATE/DELETE.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to