[sqlite] UPDATE silently failing

2015-09-23 Thread Nelson, Erik - 2
Hugues Bruant wrote on Wednesday, September 23, 2015 2:06 AM > > > in some cases the SIndex captured inside the first lambda (UPDATE > > > statement) appeared to be null even though it wasn't null in the > > > enclosing scope (setVersion_) > > > > Interesting (and disturbing) result. Is this with O

[sqlite] UPDATE silently failing

2015-09-23 Thread Rowan Worth
On 23 September 2015 at 12:32, Hugues Bruant wrote: > On Wed, Sep 23, 2015 at 12:00 AM, Rowan Worth wrote: > > > Has many possible explanations. > > I can't think of any that is consistent with the Java specification. > Yeah fair enough, SIndex looks watertight. It's still possible for some oth

[sqlite] UPDATE silently failing

2015-09-23 Thread Rowan Worth
> SIndex sidx is just a boxed immutable integer. If it were me I'd be reviewing this assumption very carefully. The sequence of events: 1. SIndex.getInt() returns 0 2. SIndex.toString() returns "1" 3. SIndex.getInt() returns 1 Has many possible explanations. You could also try 'final int sid = s

[sqlite] UPDATE silently failing

2015-09-23 Thread Hugues Bruant
> > in some cases the SIndex captured inside the first lambda > > (UPDATE statement) appeared to be null even though it wasn't null in the > > enclosing scope (setVersion_) > > Interesting (and disturbing) result. Is this with Oracle's java compiler? > Compiler is Oracle JDK 8u40-b25 on OSX Runtime

[sqlite] UPDATE silently failing

2015-09-23 Thread Hugues Bruant
On Wed, Sep 23, 2015 at 12:00 AM, Rowan Worth wrote: > > SIndex sidx is just a boxed immutable integer. > > If it were me I'd be reviewing this assumption very carefully. The sequence > of events: > public class SIndex { private final int _i; public SIndex(int i) { _i = i; } public int getInt(

[sqlite] UPDATE silently failing

2015-09-22 Thread Simon Slavin
On 22 Sep 2015, at 5:40am, Hugues Bruant wrote: > Forgot to include the db in the previous email. You can't attach files to messages in this list. If it's important, please post the file somewhere and send us -- or perhaps just a couple of people -- a URL. Simon.

[sqlite] UPDATE silently failing

2015-09-22 Thread Simon Slavin
On 22 Sep 2015, at 5:44pm, Hugues Bruant wrote: > Memory corruption seems unlikely: I would expect more errors to follow once > some piece of memory is corrupted. Valgrind is unfortunately not very > useful in this case as its OS X support is limited and it doesn't like JIT > very much. If a JV

[sqlite] UPDATE silently failing

2015-09-22 Thread Hugues Bruant
Not important. On Tue, Sep 22, 2015 at 6:00 PM, Simon Slavin wrote: > > On 22 Sep 2015, at 5:40am, Hugues Bruant wrote: > > > Forgot to include the db in the previous email. > > You can't attach files to messages in this list. If it's important, > please post the file somewhere and send us --

[sqlite] UPDATE silently failing

2015-09-22 Thread R.Smith
On 2015-09-22 03:58 PM, Hugues Bruant wrote: > On Tue, Sep 22, 2015 at 6:22 AM, Richard Hipp wrote: > >> On 9/22/15, Hugues Bruant wrote: If you can capture a malfunctioning trace, and send in the database file and the SQL statement that is running, that should allow us to locali

[sqlite] UPDATE silently failing

2015-09-22 Thread Nelson, Erik - 2
R.Smith wrote on Tuesday, September 22, 2015 10:08 AM > > On 2015-09-22 03:58 PM, Hugues Bruant wrote: > > SIndex sidx is just a boxed immutable integer. Its value is bound to > > the UPDATE and the trace shows it to be 0 But the log line printed > > when the number of rows updated is zero clearly

[sqlite] UPDATE silently failing

2015-09-22 Thread R.Smith
On 2015-09-22 06:37 AM, Hugues Bruant wrote: >> If you can capture a malfunctioning trace, and send in the database >> file and the SQL statement that is running, that should allow us to >> localize the problem. >> > Trace for the failing UPDATE: > > cv_s=1 > cv_o=b8b9f4... > cv_t=28 -> 29 > > SQ

[sqlite] UPDATE silently failing

2015-09-22 Thread Hugues Bruant
> > That does look a bit like magic - and as is 99.9% the case when > inexplicable magic happens, memory is getting corrupt or overwritten. You > are obviously prudent about this, but is there no clue when running under > Valgrind or similar for OSX? Nothing out of the ordinary or warnings? > Memor

[sqlite] UPDATE silently failing

2015-09-22 Thread Hugues Bruant
On Tue, Sep 22, 2015 at 6:22 AM, Richard Hipp wrote: > On 9/22/15, Hugues Bruant wrote: > >> > >> If you can capture a malfunctioning trace, and send in the database > >> file and the SQL statement that is running, that should allow us to > >> localize the problem. > >> > > > > Trace for the fai

[sqlite] UPDATE silently failing

2015-09-22 Thread Richard Hipp
On 9/22/15, Hugues Bruant wrote: >> >> If you can capture a malfunctioning trace, and send in the database >> file and the SQL statement that is running, that should allow us to >> localize the problem. >> > > Trace for the failing UPDATE: > > cv_s=1 The trace shows that you have this value set t

[sqlite] UPDATE silently failing

2015-09-22 Thread Hugues Bruant
Forgot to include the db in the previous email. On Tue, Sep 22, 2015 at 12:37 AM, Hugues Bruant wrote: > If you can capture a malfunctioning trace, and send in the database >> file and the SQL statement that is running, that should allow us to >> localize the problem. >> > > Trace for the failin

[sqlite] UPDATE silently failing

2015-09-22 Thread Hugues Bruant
> > If you can capture a malfunctioning trace, and send in the database > file and the SQL statement that is running, that should allow us to > localize the problem. > Trace for the failing UPDATE: cv_s=1 cv_o=b8b9f4... cv_t=28 -> 29 SQL: [update cv set cv_t=? where cv_s=? and cv_o=?] VDBE Progr

[sqlite] UPDATE silently failing

2015-09-21 Thread Simon Slavin
On 21 Sep 2015, at 10:44pm, Hugues Bruant wrote: > We've only observed this on OS X so far, with both 3.8.7 and 3.8.11.1. The > new value is always exactly the old value +1 when the statement fails. Can you reproduce this problem with the SQLite shell tool included with Mac OS X ? You should

[sqlite] UPDATE silently failing

2015-09-21 Thread James K. Lowden
On Mon, 21 Sep 2015 17:44:13 -0400 Hugues Bruant wrote: > UPDATE cv SET cv_t=? where cv_s=? and cv_o=?; > > Most of the time the row is updated as expected but in some rare cases > we've seen this statement fail silently, as in: > - the row exists > - the row it is not updated > - step ret

[sqlite] UPDATE silently failing

2015-09-21 Thread Richard Hipp
On 9/21/15, Hugues Bruant wrote: > On Mon, Sep 21, 2015 at 8:43 PM, Richard Hipp wrote: > >> On 9/21/15, Hugues Bruant wrote: >> > >> > I would be happy to build and test a patched sqlite with extra logging, >> > some sort of vdbe execution tracing >> >> Compile with -DSQLITE_DEBUG and then use

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
On Mon, Sep 21, 2015 at 8:43 PM, Richard Hipp wrote: > On 9/21/15, Hugues Bruant wrote: > > > > I would be happy to build and test a patched sqlite with extra logging, > > some sort of vdbe execution tracing > > Compile with -DSQLITE_DEBUG and then use "PRAGMA vdbe_debug=ON;" > before the offend

[sqlite] UPDATE silently failing

2015-09-21 Thread Richard Hipp
On 9/21/15, Hugues Bruant wrote: > > I would be happy to build and test a patched sqlite with extra logging, > some sort of vdbe execution tracing Compile with -DSQLITE_DEBUG and then use "PRAGMA vdbe_debug=ON;" before the offending UPDATE and turn if off afterwards. -- D. Richard Hipp drh at sq

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
On Mon, Sep 21, 2015 at 8:23 PM, Richard Hipp wrote: > On 9/21/15, Hugues Bruant wrote: > > On Mon, Sep 21, 2015 at 6:49 PM, Richard Hipp wrote: > > > >> On 9/21/15, Hugues Bruant wrote: > >> > Table schema: > >> > > >> > CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t > >> >

[sqlite] UPDATE silently failing

2015-09-21 Thread Richard Hipp
On 9/21/15, Hugues Bruant wrote: > On Mon, Sep 21, 2015 at 6:49 PM, Richard Hipp wrote: > >> On 9/21/15, Hugues Bruant wrote: >> > Table schema: >> > >> > CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t >> > integer >> > not null, primary key(cv_s, cv_o)); >> > >> > Prepared sta

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
On Mon, Sep 21, 2015 at 6:49 PM, Richard Hipp wrote: > On 9/21/15, Hugues Bruant wrote: > > Table schema: > > > > CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t integer > > not null, primary key(cv_s, cv_o)); > > > > Prepared statement: > > > > UPDATE cv SET cv_t=? where cv_s=?

[sqlite] UPDATE silently failing

2015-09-21 Thread Richard Hipp
On 9/21/15, Hugues Bruant wrote: > Table schema: > > CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t integer > not null, primary key(cv_s, cv_o)); > > Prepared statement: > > UPDATE cv SET cv_t=? where cv_s=? and cv_o=?; My guess is that the WHERE clause matches no rows. So it i

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
> > Ideally, open the database which exhibits the problem and first execute > > PRAGMA integrity_check; > Integrity check does not report any issue. > If this fails to show any problems run your UPDATE command, repeatedly if > necessary, and see if you can make the shell tool do anything that su

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
Table schema: CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t integer not null, primary key(cv_s, cv_o)); Prepared statement: UPDATE cv SET cv_t=? where cv_s=? and cv_o=?; Most of the time the row is updated as expected but in some rare cases we've seen this statement fail sile

[sqlite] Update with out without WHERE?

2015-05-24 Thread Gert Van Assche
uot;myTable" VALUES(8655,8655); > INSERT INTO "myTable" VALUES(7966,7966); > INSERT INTO "myTable" VALUES(1647,1647); > INSERT INTO "myTable" VALUES(7780,7780); > INSERT INTO "myTable" VALUES(9088,9088); > > In the following, ignore the

[sqlite] Update with out without WHERE?

2015-05-24 Thread Simon Slavin
47); INSERT INTO "myTable" VALUES(7780,7780); INSERT INTO "myTable" VALUES(9088,9088); In the following, ignore the indented rows. Those are me putting the original values back where they belong after each test. sqlite> UPDATE myTable SET x= WHERE x<100; Run Time: r

[sqlite] Update with out without WHERE?

2015-05-24 Thread Gert Van Assche
Hi all, When I do an update in a huge table, should it write it like this UPDATE T1 SET F1=replace(F1, 'x', 'y') WHERE F1 LIKE '%x%'; or without where clause like this UPDATE T1 SET F1=replace(F1, 'x', 'y'); T1 has an index on F1, which is a TEXT field. thanks gert

[sqlite] Update with out without WHERE?

2015-05-24 Thread Simon Slavin
On 24 May 2015, at 4:16pm, Gert Van Assche wrote: > When I do an update in a huge table, should it write it like this >UPDATE T1 SET F1=replace(F1, 'x', 'y') WHERE F1 LIKE '%x%'; > or without where clause like this >UPDATE T1 SET F1=replace(F1, 'x', 'y'); > > T1 has an index on

[sqlite] Update with out without WHERE?

2015-05-24 Thread Keith Medcalf
e> insert into x select random() from n where value between 1 and 10; sqlite> .eqp on sqlite> .timer on sqlite> update x set x=x where cast(x/2 as integer)*2=x; --EQP-- 0,0,0,SCAN TABLE x Run Time: real 0.087 user 0.078125 sys 0.00 sqlite> update x set x=x; --EQP-- 0,0,0,SCA

[sqlite] Update with out without WHERE?

2015-05-24 Thread Keith Medcalf
-- > From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users- > bounces at mailinglists.sqlite.org] On Behalf Of Gert Van Assche > Sent: Sunday, 24 May, 2015 09:17 > To: General Discussion of SQLite Database > Subject: [sqlite] Update with out without WHERE? > > Hi

[sqlite] UPDATE Problem

2015-03-12 Thread Peter Haworth
Thanks to all for explaining my confusion. The printf solution seems like the best way to handle this since I don't need to worry about how many decimal places are in the number.

[sqlite] UPDATE Problem

2015-03-12 Thread R.Smith
On 2015-03-12 01:27 AM, Peter Haworth wrote: > I have a table, Transactions, with a column , Value, of type NUMERIC. The > Value column is supposed to have 2 decimal places in all rows but some have > only one. SQLite has no formatting inherent to the column value, there is no such thing as "s

[sqlite] UPDATE Problem

2015-03-12 Thread Dinu Marina
Hi Peter, From https://www.sqlite.org/datatype3.html: "When text data is inserted into a NUMERIC column, the storage class of the text is converted to INTEGER or REAL (in order of preference) if such conversion is lossless and reversible"; basically any fraction you insert into a NUMERIC colu

[sqlite] UPDATE Problem

2015-03-11 Thread Peter Haworth
I have a table, Transactions, with a column , Value, of type NUMERIC. The Value column is supposed to have 2 decimal places in all rows but some have only one. To correct this I issued the following command: UPDATE Transactions SET Value=Value||0 WHERE substr(Value,-2,1)='.' No errors on execut

[sqlite] UPDATE Problem

2015-03-11 Thread Keith Medcalf
mbined: nothing works and no one knows why. >-Original Message- >From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users- >bounces at mailinglists.sqlite.org] On Behalf Of Peter Haworth >Sent: Wednesday, 11 March, 2015 17:28 >To: sqlite-users at mailingl

[sqlite] update of view via trigger

2015-03-06 Thread Igor Tandetnik
On 3/5/2015 11:58 PM, Igor Tandetnik wrote: > If the latter is OK, then you can have a single trigger doing something > like this: > > insert or replace into Clean(X, Y, Z) > select > case when new.X = ifnull(c.X, d.X) then c.X else new.X end, > case when new.Y = ifnull(c.Y, d.Y) then c.Y e

[sqlite] update of view via trigger

2015-03-06 Thread Scott Robison
On Mar 6, 2015 7:33 AM, "Igor Tandetnik" wrote: A bunch of good stuff snipped... Thanks for the alternative suggestions. In thinking it over since my message, I've decided the multiple trigger approach isn't at all bad. A little verbose, but each column of the view has its own callback and SQLite

[sqlite] update of view via trigger

2015-03-05 Thread Igor Tandetnik
On 3/5/2015 9:56 PM, Scott Robison wrote: > Finally, my question: Is there some sort of syntax that I'm missing that > would "simplify" my schema with a single update trigger, or is this the > proper way to "update" individual columns of a view? Imagine that the "clean" table has null in column X

[sqlite] update of view via trigger

2015-03-05 Thread Scott Robison
I have a use case to update a view, and wanted to make sure I'm not missing anything obvious. The basics of my schema are that I have a table from a third party that might be updated at any time. A lot of the data in that table is garbage though, and I want cleaner data, so I have a parallel table

Re: [sqlite] Update Statements using Sub query

2015-01-21 Thread MikeSnow
thanks Simon -- View this message in context: http://sqlite.1065341.n5.nabble.com/Update-Statements-using-Sub-query-tp80175p80181.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http:

Re: [sqlite] Update Statements using Sub query

2015-01-20 Thread Hick Gunter
@gmail.com] Gesendet: Dienstag, 20. Jänner 2015 14:10 An: sqlite-users@sqlite.org Betreff: [sqlite] Update Statements using Sub query I was wondering if anyone could help I am trying to use Excel to create update statements based on certain criteria. For example...this works UPDATE CDR_Ad

Re: [sqlite] Update Statements using Sub query

2015-01-20 Thread Simon Davies
014' ); sqlite> sqlite> select column_name from p where provider='abc' and version='2013-2014' and column_name='Date'; Date sqlite> sqlite> create table a( datetime text, time text ); sqlite> insert into a values( '',

[sqlite] Update Statements using Sub query

2015-01-20 Thread MikeSnow
I was wondering if anyone could help I am trying to use Excel to create update statements based on certain criteria. For example...this works UPDATE CDR_Adjusted SET "DateTime"=DATE||" "||TIME; (This is what I need, a simple Concat 2013-10-11 7:59 But when I try to do this UPDATE C

Re: [sqlite] UPDATE Help

2014-10-16 Thread Shantanu Namjoshi
: [sqlite] UPDATE Help On 15 Oct 2014, at 1:10am, Shantanu Namjoshi wrote: > ALTER TABLE dailydelete ADD COLUMN SMB varchar(11); If you find yourself doing things like this your schema is messed up. SMB is obviously data, not a column. Redesign your table so that HML, SMB, UMD and Rf are val

Re: [sqlite] UPDATE Help

2014-10-16 Thread Shantanu Namjoshi
SQLite Database Subject: Re: [sqlite] UPDATE Help On Tue, Oct 14, 2014 at 8:10 PM, Shantanu Namjoshi < shantanu.namjo...@business.uconn.edu> wrote: > > UPDATE dailydelete > SET SMB = (SELECT dailyfactors.SMB FROM dailyfactors WHERE > dailydelete.data = dailyfactors.Date),

Re: [sqlite] UPDATE Help

2014-10-14 Thread Richard Hipp
On Tue, Oct 14, 2014 at 8:10 PM, Shantanu Namjoshi < shantanu.namjo...@business.uconn.edu> wrote: > > UPDATE dailydelete > SET SMB = (SELECT dailyfactors.SMB FROM dailyfactors WHERE > dailydelete.data = dailyfactors.Date), > SET Rf = (SELECT dailyfactors.Rf FROM dailyfactors WHERE dailydelete.data

Re: [sqlite] UPDATE Help

2014-10-14 Thread Simon Slavin
On 15 Oct 2014, at 1:10am, Shantanu Namjoshi wrote: > ALTER TABLE dailydelete ADD COLUMN SMB varchar(11); If you find yourself doing things like this your schema is messed up. SMB is obviously data, not a column. Redesign your table so that HML, SMB, UMD and Rf are values in a column, not

[sqlite] UPDATE Help

2014-10-14 Thread Shantanu Namjoshi
Hello, I was writing for some help with a problem that has me stumped. I have two tables in a DB. Table1 = dailydelete Table2 = dailyfactors. dailyfactors is a list of dates and some corresponding information HML, SMB, UMD and Rf for each of these dates dates are NOT repeated in this table dai

Re: [sqlite] Update a BLOB

2014-06-23 Thread Simon Slavin
> On 23 Jun 2014, at 4:10pm, Carlos Ferreira wrote: > > To access Blobs I use the direct access BLOB api from SQLite. > > However, what is the best way to update a record that contains a BLOB, and > the only goals is to update the BLOB... > > The BLOB may shrink or increase...and that is the

[sqlite] Update a BLOB

2014-06-23 Thread Carlos Ferreira
Hello, One question. To access Blobs I use the direct access BLOB api from SQLite. However, what is the best way to update a record that contains a BLOB, and the only goals is to update the BLOB... The BLOB may shrink or increase...and that is the reason why I cannot use the BLOB Write and..

Re: [sqlite] UPDATE and default values

2013-11-10 Thread Simon Slavin
On 10 Nov 2013, at 9:03pm, Ulrich Goebel wrote: > I want to have a column 'last_changed' in a table, which shows the date of > the last change (inser or update) of the row. I though the default value in > the CREATE TABLE was a good idea: > > CREATE TABLE ( > id integer, > name text, > las

[sqlite] UPDATE and default values

2013-11-10 Thread Ulrich Goebel
Hallo, I want to have a column 'last_changed' in a table, which shows the date of the last change (inser or update) of the row. I though the default value in the CREATE TABLE was a good idea: CREATE TABLE ( id integer, name text, last_changed text default current_date ) That works for

Re: [sqlite] Update and GROUP BY

2013-11-07 Thread Gert Van Assche
James, probably a view is not slower, but if you need this data several times... I wanted to do an update because we are using this data several times in the process, and I did not want to add the missing pieces each time. gert 2013/11/7 James K. Lowden > On Mon, 4 Nov 2013 13:01:37 +0100 >

Re: [sqlite] Update and GROUP BY

2013-11-06 Thread James K. Lowden
On Mon, 4 Nov 2013 13:01:37 +0100 Gert Van Assche wrote: > Thanks James -- the select query is something I could do, but the > update one I could not get that one right. > I was considering to create a new table based on the select query, > but since the real data set is millions of records, an

Re: [sqlite] Update and GROUP BY

2013-11-04 Thread Gert Van Assche
Thanks James -- the select query is something I could do, but the update one I could not get that one right. I was considering to create a new table based on the select query, but since the real data set is millions of records, an update was the best solution. As always, thanks for your help. g

Re: [sqlite] Update and GROUP BY

2013-11-03 Thread James K. Lowden
On Sat, 2 Nov 2013 18:06:30 +0100 Gert Van Assche wrote: > CREATE TABLE T (N, V, G); > INSERT INTO T VALUES('a', 1, 'x'); > INSERT INTO T VALUES('b', 3, 'x'); > INSERT INTO T VALUES('c', null, 'x'); > INSERT INTO T VALUES('d', 80, 'y'); > INSERT INTO T VALUES('e', null, 'y'); > INSERT INTO T VALU

Re: [sqlite] Update and GROUP BY

2013-11-02 Thread Jim Callahan
Good question Gert. Good solution, Igor and I like Keith's formatting. I thought the list might be interested in some of the statistical issues involved in determining if this method of replacing null values is an appropriate method for your data analysis and alternatives that are available. The

Re: [sqlite] Update and GROUP BY

2013-11-02 Thread Gert Van Assche
sqlite-users- > >boun...@sqlite.org] On Behalf Of Gert Van Assche > >Sent: Saturday, 2 November, 2013 11:07 > >To: sqlite-users > >Subject: [sqlite] Update and GROUP BY > > > >All, I have this table: > > > >DROP TABLE T; > >CREATE TABLE T (N, V

Re: [sqlite] Update and GROUP BY

2013-11-02 Thread Gert Van Assche
Igor, that is exactly what I need. I also understand how it is done now. Thanks! gert 2013/11/2 Igor Tandetnik > On 11/2/2013 1:06 PM, Gert Van Assche wrote: > >> All, I have this table: >> >> DROP TABLE T; >> CREATE TABLE T (N, V, G); >> INSERT INTO T VALUES('a', 1, 'x'); >> INSERT INTO T VA

Re: [sqlite] Update and GROUP BY

2013-11-02 Thread Keith Medcalf
update the value of V in rows where V IS NULL ... >-Original Message- >From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- >boun...@sqlite.org] On Behalf Of Gert Van Assche >Sent: Saturday, 2 November, 2013 11:07 >To: sqlite-users >Subject: [sqlite] Update and GROUP

Re: [sqlite] Update and GROUP BY

2013-11-02 Thread Igor Tandetnik
On 11/2/2013 1:06 PM, Gert Van Assche wrote: All, I have this table: DROP TABLE T; CREATE TABLE T (N, V, G); INSERT INTO T VALUES('a', 1, 'x'); INSERT INTO T VALUES('b', 3, 'x'); INSERT INTO T VALUES('c', null, 'x'); INSERT INTO T VALUES('d', 80, 'y'); INSERT INTO T VALUES('e', null, 'y'); INSER

[sqlite] Update and GROUP BY

2013-11-02 Thread Gert Van Assche
All, I have this table: DROP TABLE T; CREATE TABLE T (N, V, G); INSERT INTO T VALUES('a', 1, 'x'); INSERT INTO T VALUES('b', 3, 'x'); INSERT INTO T VALUES('c', null, 'x'); INSERT INTO T VALUES('d', 80, 'y'); INSERT INTO T VALUES('e', null, 'y'); INSERT INTO T VALUES('f', 60, 'y'); INSERT INTO T VA

Re: [sqlite] UPDATE question

2013-09-07 Thread Peter Haworth
0 (EDT) > From: j.merr...@enlyton.com > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] UPDATE question > Message-ID: <1378503959.951430...@apps.rackspace.com> > Content-Type: text/plain;charset=UTF-8 > > I propose that you remove the unique index because SQLite does

Re: [sqlite] UPDATE question

2013-09-07 Thread Marc L. Allen
Yes, thanks. I was mistaken. On Sep 6, 2013, at 9:27 PM, "James K. Lowden" wrote: > On Fri, 6 Sep 2013 07:56:53 -0500 > "Marc L. Allen" wrote: > >> I don't think it's a bug. > > It is a bug as long as the behavior is in exception to the > documentation. > >> I don't believe there's any d

Re: [sqlite] UPDATE question

2013-09-07 Thread Luuk
ate table i ( i int primary key ); sqlite> insert into i values (1); sqlite> insert into i values (2); sqlite> update i set i = i + 1; SQL error: column i is not unique sqlite> drop table i; sqlite> create table i ( i int primary key ); sqlite> insert into i values (2); sqlite>

Re: [sqlite] UPDATE question

2013-09-07 Thread ibrahim
Further comment : If you want to implement a sequence of records in a table you can do it much faster with only on record to update when you insert a value in the middle of this sequence. For this purpose you shouldn't use a pseudo array but a single or double ended queue with only one trigger

Re: [sqlite] UPDATE question

2013-09-07 Thread ibrahim
t into t1 values (4, 'blue', 4) ; insert into t1 values (5, 'blue', 5) ; before updating your unique index just drop and recreate it ! Behaviour till now : sqlite> select *from t1 ; 1|blue|1 2|blue|2 3|blue|3 4|blue|4 5|blue|5 sqlite> update t1 set seq=seq+1 where pk

Re: [sqlite] UPDATE question

2013-09-06 Thread James K. Lowden
On Fri, 6 Sep 2013 17:45:59 -0400 (EDT) j.merr...@enlyton.com wrote: > I propose that you remove the unique index because SQLite does not > handle the update case the way you want. The correct general approach, in light of observed behavior, 1. begin IMMEDIATE transaction 2. select rows into

Re: [sqlite] UPDATE question

2013-09-06 Thread James K. Lowden
lite> insert into i values (1); sqlite> insert into i values (2); sqlite> update i set i = i + 1; SQL error: column i is not unique --jkl ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] UPDATE question

2013-09-06 Thread James K. Lowden
On Fri, 6 Sep 2013 07:56:53 -0500 "Marc L. Allen" wrote: > I don't think it's a bug. It is a bug as long as the behavior is in exception to the documentation. > I don't believe there's any defined rule for how SQL should behave, > is there? Of course there is. Hundreds of pages describe

Re: [sqlite] UPDATE question

2013-09-06 Thread j . merrill
you wanted to, you could have your initial "open the database" code check for duplicates across those columns (and that 1 is the lowest Sequence for each Name) -- then at least you'd know that you'd had one of those bugs. J. Merrill -Original Message- From: Peter H

Re: [sqlite] UPDATE question

2013-09-06 Thread Simon Slavin
On 6 Sep 2013, at 4:08pm, Simon Slavin wrote: > Right. As I posted in my message that I had tested, this isn't being done > correctly. A conflict isn't a conflict until the write, and the write > doesn't happen until the COMMIT. Therefore conflict testing needs to happen > at the commit, fo

Re: [sqlite] UPDATE question

2013-09-06 Thread Igor Tandetnik
On 9/6/2013 1:05 PM, ibrahim wrote: Perhaps you should really try it out cause my suggestion is totally different from yours it uses a temporary table it works. create table t1 (pk integer primary key, name text, seq integer) ; You missed the whole "Name/Sequence pair of columns is defined as

Re: [sqlite] UPDATE question

2013-09-06 Thread ibrahim
On 06.09.2013 20:52, Igor Tandetnik wrote: On 9/6/2013 1:05 PM, ibrahim wrote: Perhaps you should really try it out cause my suggestion is totally different from yours it uses a temporary table it works. create table t1 (pk integer primary key, name text, seq integer) ; You missed the whole "

Re: [sqlite] UPDATE question

2013-09-06 Thread ibrahim
On 05.09.2013 20:20, Peter Haworth wrote: I have a table with the following (simplified) structure PKeyINTEGER PRIMARY KEY NameTEXT Sequence INTEGER The Name/Sequence pair of columns is defined as UNIQUE I need to insert a new row into a point between two sequence numbers. For example, if the

Re: [sqlite] UPDATE Question

2013-09-06 Thread Peter Haworth
st sequence number. EXPLAIN QUERY PLAN indicates that the TestIndex index was used. Pete On Fri, Sep 6, 2013 at 9:00 AM, wrote: > Message: 27 > Date: Fri, 6 Sep 2013 07:50:39 -0500 > From: "Marc L. Allen" > To: General Discussion of SQLite Database > Subject

Re: [sqlite] UPDATE question

2013-09-06 Thread ibrahim
t;blue", 2) ; insert into t1 (pk, name, seq) values (3, "blue", 3) ; insert into t1 (pk, name, seq) values (4, "blue", 4) ; insert into t1 (pk, name, seq) values (5, "blue", 5) ; sqlite> select * from t1 ; 1|blue|1 2|blue|2 3|blue|3 4|blue|4 5|blue|5 sqlite

Re: [sqlite] UPDATE question

2013-09-06 Thread ibrahim
t;blue", 2) ; insert into t1 (pk, name, seq) values (3, "blue", 3) ; insert into t1 (pk, name, seq) values (4, "blue", 4) ; insert into t1 (pk, name, seq) values (5, "blue", 5) ; sqlite> select * from t1 ; 1|blue|1 2|blue|2 3|blue|3 4|blue|4 5|blue|5 sqlite

Re: [sqlite] UPDATE question

2013-09-06 Thread ibrahim
On 05.09.2013 20:20, Peter Haworth wrote: I have a table with the following (simplified) structure PKeyINTEGER PRIMARY KEY NameTEXT Sequence INTEGER The Name/Sequence pair of columns is defined as UNIQUE I need to insert a new row into a point between two sequence numbers. For example, if the

Re: [sqlite] UPDATE question

2013-09-06 Thread Dominique Devienne
On Fri, Sep 6, 2013 at 5:41 PM, ibrahim wrote: > You can let sqlite handle the creation of a temporary table by : > > update t1 set seq=seq+1 where pk in (select pk from t1 where seq >= 3 > order by seq desc) ; > > afterwards you can insert. Unless I'm misunderstanding you, I already tried tha

Re: [sqlite] UPDATE question

2013-09-06 Thread Marc L. Allen
Discussion of SQLite Database Subject: Re: [sqlite] UPDATE question On Fri, Sep 6, 2013 at 11:00 AM, Dominique Devienne wrote: > Myself, if I'm "thinking in sets", all implementation details aside, > the UPDATE statement looks fine and correct, and I'd have expected > SQLi

Re: [sqlite] UPDATE question

2013-09-06 Thread Dan Kennedy
, 2013 11:07 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] UPDATE question On Fri, Sep 6, 2013 at 11:00 AM, Dominique Devienne wrote: Myself, if I'm "thinking in sets", all implementation details aside, the UPDATE statement looks fine and correct, and I'd

Re: [sqlite] UPDATE question

2013-09-06 Thread Simon Slavin
On 6 Sep 2013, at 1:50pm, Marc L. Allen wrote: > No one commented on my second thread (written after I actually understood the > problem!). > > But, I proposed a two update sequence to do it. > > UPDATE table SET Sequence = -(Sequence + 1) WHERE Sequence >= seq_to_insert > AND Name = name_

Re: [sqlite] UPDATE question

2013-09-06 Thread Marc L. Allen
qlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of kyan Sent: Friday, September 06, 2013 10:41 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] UPDATE question On Thu, Sep 5, 2013 at 9:20 PM, Peter Haworth wrote: > I have a table with the f

Re: [sqlite] UPDATE question

2013-09-06 Thread Dominique Devienne
On Fri, Sep 6, 2013 at 2:50 PM, Marc L. Allen wrote: > No one commented on my second thread (written after I actually understood > the problem!). > > But, I proposed a two update sequence to do it. > > UPDATE table SET Sequence = -(Sequence + 1) WHERE Sequence >= > seq_to_insert AND Name = name_to

Re: [sqlite] UPDATE question

2013-09-06 Thread Richard Hipp
On Fri, Sep 6, 2013 at 11:00 AM, Dominique Devienne wrote: > Myself, if I'm "thinking in sets", all implementation details aside, the > UPDATE statement looks fine and correct, and I'd have expected SQLite to > support it. > > But I'm just waiting to read Dr. Hipp's own read on this now. --DD I

Re: [sqlite] UPDATE question

2013-09-06 Thread kyan
On Thu, Sep 5, 2013 at 9:20 PM, Peter Haworth wrote: > I have a table with the following (simplified) structure > > PKeyINTEGER PRIMARY KEY > NameTEXT > Sequence INTEGER > > The Name/Sequence pair of columns is defined as UNIQUE > > I need to insert a new row into a point between two sequence num

Re: [sqlite] UPDATE question

2013-09-06 Thread Igor Tandetnik
On 9/6/2013 8:50 AM, Marc L. Allen wrote: But, I proposed a two update sequence to do it. UPDATE table SET Sequence = -(Sequence + 1) WHERE Sequence >= seq_to_insert AND Name = name_to_insert UPDATE table SET Sequence = -Sequence WHERE Sequence < 0 AND Name = name_to_insert I've used this sy

Re: [sqlite] UPDATE question

2013-09-06 Thread Marc L. Allen
Discussion of SQLite Database Subject: Re: [sqlite] UPDATE question By forcing the "physical order" of the rows to be reversed, the UPDATE succeeds. I suspect this is just a bug, and Dr Hipp will fix it (and if not document it somehow). This email and any attachments are only for use by

Re: [sqlite] UPDATE question

2013-09-06 Thread Marc L. Allen
-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Dominique Devienne Sent: Friday, September 06, 2013 3:28 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] UPDATE question On Fri, Sep 6, 2013 at 6:21 AM, James K. Lowden wrote: > Here's how Ma

Re: [sqlite] UPDATE question

2013-09-06 Thread Dominique Devienne
e3 SQLite version 3.7.15.2 2013-01-09 11:53:05 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table jkl (name text, seq number, unique (name, seq)); sqlite> insert into jkl values ('blue', 1), ('blue', 2), (

Re: [sqlite] UPDATE question

2013-09-06 Thread Dominique Devienne
On Fri, Sep 6, 2013 at 6:21 AM, James K. Lowden wrote: > That's perfectly good SQL. SQLite is simply not executing the > update atomically. > > Anyone tempted to protest may be forgetting "atomic" means more than > "all or nothing". It also means the DBMS may execute the transaction > however it

Re: [sqlite] UPDATE question

2013-09-05 Thread James K. Lowden
works: sqlite> create table a (a int, b int check( a + b = 3)); sqlite> insert into a values (1, 2); sqlite> select * from a; a b -- -- 1 2 sqlite> update a set a = b, b = a; sqlite> select * from a; a b --

Re: [sqlite] UPDATE question

2013-09-05 Thread Simon Slavin
On 5 Sep 2013, at 7:20pm, Peter Haworth wrote: > That works fine but wondering if there might be a single UPDATE statement > that could do this for me. I can use the WHERE clause to select sequence > 3,4, and 5 but the UPDATE has to process the rows in descending sequence > order to avoid UNIQ

Re: [sqlite] UPDATE question

2013-09-05 Thread Marc L. Allen
0 AND Name = name_to_insert -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Peter Haworth Sent: Thursday, September 05, 2013 2:21 PM To: sqlite-users Subject: [sqlite] UPDATE question I have a table with the following (simplified

Re: [sqlite] UPDATE question

2013-09-05 Thread Marc L. Allen
To: sqlite-users Subject: [sqlite] UPDATE question I have a table with the following (simplified) structure PKeyINTEGER PRIMARY KEY NameTEXT Sequence INTEGER The Name/Sequence pair of columns is defined as UNIQUE I need to insert a new row into a point between two sequence numbers. For example,

[sqlite] UPDATE question

2013-09-05 Thread Peter Haworth
I have a table with the following (simplified) structure PKeyINTEGER PRIMARY KEY NameTEXT Sequence INTEGER The Name/Sequence pair of columns is defined as UNIQUE I need to insert a new row into a point between two sequence numbers. For example, if the existing rows are: Name Sequence ---

<    1   2   3   4   5   6   7   8   >