Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-17 Thread David Raymond
ing a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key Hello, I have a table of records in a Sqlite DB. It contains 5 records. Each record has a time-stamp which is not guaranteed to be unique. To preserve order (which is important in

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-16 Thread Chris Locke
But be careful, as you can't change all records from 3 to 4 and then 4 to 5, as the 4 to 5 will contain the records you've just moved from 3 to 4 Canofworms.jpg. ;) Thanks, Chris On 15 Oct 2016 5:46 p.m., "Richard Damon" wrote: > On 10/15/16 12:15 PM, Simon Slavin wrote: > >> On 14 Oct

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Simon Slavin
On 16 Oct 2016, at 12:32am, Keith Medcalf wrote: > The whole reason for using a "manual sortation field" is so that a human can > decide what order to display the data in via a "manual" operation. You answered the question. To get as close to the OP's requirements as possible the order needs

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Keith Medcalf
; > Delvin > > > > > > -Original Message- > > From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] > On Behalf Of Jens Alfke > > Sent: Saturday, 15 October, 2016 13:42 > > To: SQLite mailing list > > Subject: Re: [sqli

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Simon Slavin
On 15 Oct 2016, at 11:43pm, Richard Damon wrote: > My thought is that if the first level of sort IS by Date-Time, and then by > some other condition, then the real solution is to use an ORDER BY clause on > the Date-Time field and then some other field to implement the duplicate > value order

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Richard Damon
d (anywhere) into a table of ordered records that have an integer auto-increment primary key On Oct 15, 2016, at 11:12 AM, Keith Medcalf wrote: Is there a way to do this automagically (like a specialized INSERT command?) in Sqlite? Unfortunately no, there is no way to do this on *AN

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Luca Olivetti
El 15/10/16 a les 20:53, Jens Alfke ha escrit: [*] I have to insert records in the given order but the user may occasionally rearrange them. What happens if the user makes a series of rearrangements that triggers a collision? It’s not that far fetched; all I have to do is, one at a time, d

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Delvin
unique. Thanks Delvin -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Jens Alfke Sent: Saturday, 15 October, 2016 13:42 To: SQLite mailing list Subject: Re: [sqlite] Inserting a new record (anywhere) into a table of ordered

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread J Decker
On Sat, Oct 15, 2016 at 11:58 AM, Keith Medcalf wrote: > > I'd just sort the data into the order I wanted the result set presented in > using an ORDER BY clause on the SELECT which retrieves the data ... > One other thought I saw someone else propose a while ago... treat the number as floating p

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread J Decker
On Sat, Oct 15, 2016 at 10:18 AM, Stephen Chrzanowski wrote: > What you want to do is called using a linked list. Each record knows what > its previous record is. > > SQLite doesn't exactly have that capability directly. No SQL engine that I > know of has the capability. Each row is unaware of

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Keith Medcalf
I'd just sort the data into the order I wanted the result set presented in using an ORDER BY clause on the SELECT which retrieves the data ... > > On Oct 15, 2016, at 11:12 AM, Keith Medcalf wrote: > > > >> Is there a way to do this automagically (like a specialized INSERT > >> command?) in Sql

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Jens Alfke
> On Oct 15, 2016, at 11:38 AM, Luca Olivetti wrote: > > I'm aware of the limitation but for my application[*] it is perfectly fine, > maybe it is also ok for the OP, maybe it isn't. OK, but if you’re proposing a solution that you know has major limitations, I think it’s a good idea to disclo

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Jens Alfke
> On Oct 15, 2016, at 11:12 AM, Keith Medcalf wrote: > >> Is there a way to do this automagically (like a specialized INSERT >> command?) in Sqlite? > > Unfortunately no, there is no way to do this on *ANY* database that uses the > relational database model. There’s no need to dive into datab

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Luca Olivetti
El 15/10/16 a les 19:49, Jens Alfke ha escrit: On Oct 15, 2016, at 7:42 AM, Luca Olivetti wrote: Instead of an autoincrement you could increment it manually in, say, 1000 increments. Then, when you have to insert something between 1000 and 2000 you just use 1500. Unfortunately this breaks

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Keith Medcalf
On Friday, 14 October, 2016 07:29, Thom Wharton wrote: > I have a table of records in a Sqlite DB. It contains 5 records. Each > record has a time-stamp which is not guaranteed to be unique. To > preserve order (which is important in my project), I've given the table > an integer primary key

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Jens Alfke
> On Oct 15, 2016, at 7:42 AM, Luca Olivetti wrote: > > Instead of an autoincrement you could increment it manually in, say, 1000 > increments. > Then, when you have to insert something between 1000 and 2000 you just use > 1500. Unfortunately this breaks down after log2(1000) ≈ 10 insertions,

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Stephen Chrzanowski
What you want to do is called using a linked list. Each record knows what its previous record is. SQLite doesn't exactly have that capability directly. No SQL engine that I know of has the capability. Each row is unaware of any other row in that table. That row is a unique entity to itself, ob

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Richard Damon
On 10/15/16 12:15 PM, Simon Slavin wrote: On 14 Oct 2016, at 2:29pm, Thom Wharton wrote: I want to be able to programmatically insert a new record anywhere in that table. Let's suppose I want to create a new record between the records whose ID are 2 and 3. This new record would need to take

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Simon Slavin
On 14 Oct 2016, at 2:29pm, Thom Wharton wrote: > I want to be able to programmatically insert a new record anywhere in that > table. Let's suppose I want to create a new record between the records whose > ID are 2 and 3. This new record would need to take the ID of 3, and all > subsequent re

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Luca Olivetti
El 14/10/16 a les 15:29, Thom Wharton ha escrit: Hello, I have a table of records in a Sqlite DB. It contains 5 records. Each record has a time-stamp which is not guaranteed to be unique. To preserve order (which is important in my project), I've given the table an integer primary key (called

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Richard Damon
If you sort rule is by Date (and time) and ID as a tie breaker, then you should have your sort key be THAT, not just your ID field (I.e., your index/order would be Data, ID not just ID) An auto-increment primary key is to give every record a unique id to refer to it, the only order that it can

Re: [sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Igor Tandetnik
On 10/14/2016 9:29 AM, Thom Wharton wrote: IDDate Type Size Data 110OCT-08:13:47 Ether28sddsgsd... 210OCT-08:13:52 Ether77fdasfdsdsddssdg... 310OCT-08:13:52 Ether44zeasfkkfa... 410OCT-08:

[sqlite] Inserting a new record (anywhere) into a table of ordered records that have an integer auto-increment primary key

2016-10-15 Thread Thom Wharton
Hello, I have a table of records in a Sqlite DB. It contains 5 records. Each record has a time-stamp which is not guaranteed to be unique. To preserve order (which is important in my project), I've given the table an integer primary key (called ID) that is auto-increment. Let's say I have