Hi, guys,

On Fri, Oct 25, 2013 at 6:19 AM, Igor Tandetnik <i...@tandetnik.org> wrote:

> On 10/24/2013 10:48 PM, Igor Korot wrote:
>
>> INSERT INTO leagueplayers SELECT players.playerid, %d, ... ORDER BY
>> players.rank;
>>
>> Now my language of choice is C++ and what I'm looking for is a way to
>> populate the current_rank and original_rank in the leagueplayers table.
>> They should come up as auto-incremented values.
>> So in the "INSERT INTO" query instead of "..." I should have some kind of
>> function or something that will give me values of 1,2,3,4 and so forth.
>>
>
> INSERT INTO leagueplayers
> SELECT p1.playerid, :leagueId, count(*), count(*)
> FROM players p1 JOIN players p2 ON (p2.rank < p1.rank or (p2.rank =
> p1.rank and p2.playerid <= p1.playerid))
> GROUP BY p1.playerid;
>

If I do something like this:

CREATE TRIGGER AFTER INSERT
{
SELECT max( current_rank ) AS a FROM leagueplayers WHERE leagueid = 1;
UPDATE leagueplayers SET current_rank = a WHERE leagueid = 1 AND
current_rank IS NULL;
}

Will this work? Is "INSERT INTO... SELECT()" will work with such trigger?
Then I will not need to change the code of my program...

Thank you.


> --
> Igor Tandetnik
>
>
> ______________________________**_________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to