Re: [sqlite] Is there a function that return an autoimcremented value?

2013-10-25 Thread Igor Korot
Igor, On Fri, Oct 25, 2013 at 3:26 PM, Igor Tandetnik wrote: > On 10/25/2013 5:53 PM, Igor Korot wrote: > >> If I do something like this: >> >> CREATE TRIGGER AFTER INSERT >> { >> SELECT max( current_rank ) AS a FROM leagueplayers WHERE leagueid = 1; >> UPDATE leagueplayers

Re: [sqlite] Is there a function that return an autoimcremented value?

2013-10-25 Thread Igor Tandetnik
On 10/25/2013 5:53 PM, Igor Korot wrote: 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; } Something along these lines might

Re: [sqlite] Is there a function that return an autoimcremented value?

2013-10-25 Thread Igor Korot
Hi, guys, On Fri, Oct 25, 2013 at 6:19 AM, Igor Tandetnik 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

Re: [sqlite] Is there a function that return an autoimcremented value?

2013-10-25 Thread Igor Tandetnik
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

Re: [sqlite] Is there a function that return an autoimcremented value?

2013-10-25 Thread Clemens Ladisch
Stephan Beal wrote: > On Fri, Oct 25, 2013 at 12:51 PM, Clemens Ladisch wrote: >> CREATE TEMP TABLE t(playerid, leagueid, auto_rank INTEGER PRIMARY KEY); >> INSERT INTO t(playerid, leagueid) SELECT players.playerid, %d FROM ...; >> INSERT INTO leagueplayers(playerid, leagueid,

Re: [sqlite] Is there a function that return an autoimcremented value?

2013-10-25 Thread Stephan Beal
On Fri, Oct 25, 2013 at 12:51 PM, Clemens Ladisch wrote: > CREATE TEMP TABLE t(playerid, leagueid, auto_rank INTEGER PRIMARY KEY); > INSERT INTO t(playerid, leagueid) SELECT players.playerid, %d FROM ...; > INSERT INTO leagueplayers(playerid, leagueid, current_rank,

Re: [sqlite] Is there a function that return an autoimcremented value?

2013-10-25 Thread Clemens Ladisch
Igor Korot wrote: > On Fri, Oct 25, 2013 at 2:12 AM, Clemens Ladisch wrote: >> Igor Korot wrote: >>> 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. >>> Is there a

Re: [sqlite] Is there a function that return an autoimcremented value?

2013-10-25 Thread Igor Korot
Hi, Clemens, On Fri, Oct 25, 2013 at 2:12 AM, Clemens Ladisch wrote: > Igor Korot wrote: > > 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. > > Autoincrementing

Re: [sqlite] Is there a function that return an autoimcremented value?

2013-10-25 Thread Clemens Ladisch
Igor Korot wrote: > 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. Autoincrementing works only for INTEGER PRIMARY KEY columns. > Is there a way to do that or I will have to change the

[sqlite] Is there a function that return an autoimcremented value?

2013-10-24 Thread Igor Korot
Hi, ALL, Consider the following schema: CREATE TABLE players( playerid INTEGER PRIMARY KEY, name TEXT, rank INTEGER); CREATE TABLE leagueplayers( playerid INTEGER, leagueid INTEGER, current_rank INTEGER original_rank INTEGER); The fields rank, current_rank and original_rank are recent addition