Re: [sqlite] INSERT OR REPLACE in trigger body fails with UNIQUE constraint

2020-01-03 Thread Clemens Ladisch
Mike _ wrote: > The trigger documentation says: "An ON CONFLICT clause may be specified as > part of an UPDATE or INSERT action within the body of the trigger. However > if an ON CONFLICT clause is specified as part of the statement causing the > trigger to fire, then conflict handling policy of th

Re: [sqlite] INSERT OR REPLACE and foreign keys

2018-10-23 Thread Olivier Mascia
> Le 23 oct. 2018 à 19:52, Roman Fleysher a > écrit : > > I am using INSERT OR REPLACE ... it seems that "replace" is implemented as > "delete then insert" rather than "update". Is that normal and expected? Am I > doing something wrong? Normal and expected. Check https://www.sqlite.org/lang_

Re: [sqlite] INSERT OR REPLACE and foreign keys

2018-10-23 Thread Shawn Wagner
That's normal. It deletes the conflicting row and inserts a new one. On Tue, Oct 23, 2018, 10:58 AM Roman Fleysher < roman.fleys...@einstein.yu.edu> wrote: > Dear SQLiters, > > I am using INSERT OR REPLACE to update a table which holds a column which > servers as a foreign key. But I noticed a st

Re: [sqlite] insert or replace performance with self "references" column

2018-07-02 Thread Simon Slavin
On 2 Jul 2018, at 2:45pm, Allen wrote: > My C program was creating a "Parent_Index" on two different tables, so > the second Parent_Index on the Transactions table was not being > created, and this was causing the "replace" to do a table scan. I > solved the problem by making the index names glo

Re: [sqlite] insert or replace performance with self "references" column

2018-07-02 Thread Allen
ausing the "replace" to do a table scan. I solved the problem by making the index names globally unique. Thanks again. > Date: Thu, 28 Jun 2018 18:09:09 +0100 > From: Simon Slavin > To: SQLite mailing list > Subject: Re: [sqlite] insert or replace performance with se

Re: [sqlite] insert or replace performance with self "references" column

2018-06-28 Thread Simon Slavin
On 27 Jun 2018, at 11:20pm, Allen wrote: > I have a table with an additional index and a query: > > "create table Transactions (Id integer primary key not null, Parent > references Transactions(id), Body varchar);" > > "create index Parent_Index on Transactions (Parent);" > > EXPLAIN QUERY PLA

Re: [sqlite] insert or replace performance with self "references" column

2018-06-28 Thread Clemens Ladisch
Allen wrote: > create table Transactions (Id integer primary key not null, Parent references > Transactions(id), Body varchar); > create index Parent_Index on Transactions (Parent); > > EXPLAIN QUERY PLAN insert or replace into Transactions (Id, Parent, Body) > values (?1, ?2, ?3); > 23 0 0 SCAN

Re: [sqlite] insert or replace performance with self "references" column

2018-06-27 Thread Donald Griggs
On Wed, Jun 27, 2018, 7:47 PM Keith Medcalf wrote: > > If you give the parent column a proper affinity (ie, integer) do you get > "happiness making" results? > > --- > The fact that there's a Highway to Hell but only a Stairway to Heaven says > a lot about anticipated traffic volume. > > > >-

Re: [sqlite] insert or replace performance with self "references" column

2018-06-27 Thread Keith Medcalf
If you give the parent column a proper affinity (ie, integer) do you get "happiness making" results? --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original Message- >From: sqlite-users [mailto:sqlite-users- >bo

Re: [sqlite] INSERT OR REPLACE statement and triggers

2017-12-23 Thread David Raymond
sert||2||new two Before Delete|2||two| After Delete|2||two| After Insert||2||new two Before Insert||3||new three sqlite> -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of skywind mailing lists Sent: Saturday, December 23, 2017

Re: [sqlite] INSERT OR REPLACE statement and triggers

2017-12-23 Thread skywind mailing lists
Hello, thanks for the documentation references! Regards, Hartwig > Am 2017-12-23 um 13:18 schrieb J. King : > > The documentation states that in cases of replacement the DELETE trigger only > fires if recursive triggers are enabled. Recursive triggers are currently off > by default. > >

Re: [sqlite] INSERT OR REPLACE statement and triggers

2017-12-23 Thread J. King
The documentation states that in cases of replacement the DELETE trigger only fires if recursive triggers are enabled. Recursive triggers are currently off by default. On December 23, 2017 7:05:5

Re: [sqlite] INSERT OR REPLACE statement and triggers

2017-12-23 Thread R Smith
On 2017/12/23 1:57 PM, skywind mailing lists wrote: Hello, I have checked the documentation but did not find an explicit answer concerning my case. Of course I can test it but this does not mean that the functionality is guaranteed also for future versions. Assume I have an insertion stateme

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-15 Thread James K. Lowden
On Tue, 12 Jul 2016 15:35:20 +0200 Dominique Devienne wrote: > Now we know OR REPLACE is never what we want (in our use cases), Besides being nonstandard, REPLACE is not atomic. I haven't seen the use case that benefits from those characteristics but, judging from this list, you're not the firs

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread R Smith
On 2016/07/12 3:55 PM, R Smith wrote: On 2016/07/12 2:12 PM, Dominique Devienne wrote: In the session above, we can see that an insert or replace w/o an id (the PK) value, results in the id changing in the table, which is not what we'd like. etc. By the way, another important problem with

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread R Smith
On 2016/07/12 2:12 PM, Dominique Devienne wrote: In the session above, we can see that an insert or replace w/o an id (the PK) value, results in the id changing in the table, which is not what we'd like. If you ask any DB engine to INSERT, and you do not specify the autoinc/pk/identity ID, t

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread Dominique Devienne
Thank you all, Clemens, Richard, Simon, Hick. Now we know OR REPLACE is never what we want (in our use cases), and will rewrite into two statements, as Clemens and Simon indicated. --DD ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org h

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread Hick Gunter
sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Dominique Devienne Gesendet: Dienstag, 12. Juli 2016 14:39 An: SQLite mailing list Betreff: Re: [sqlite] insert or replace on PK and UNIQUE INDEX On Tue, Jul 12, 2016 at 2:31 PM, Richard Hipp wrote: > On 7/12/16, Dominique Devienne

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread Simon Slavin
On 12 Jul 2016, at 1:39pm, Dominique Devienne wrote: > So the plural in "deletes pre-existing rows" explain that in my second > example, > with both the PK and NK where each point to different rows, both rows are > first > deleted, then the new row is inserted? Correct. There is a common assum

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread Dominique Devienne
On Tue, Jul 12, 2016 at 2:31 PM, Richard Hipp wrote: > On 7/12/16, Dominique Devienne wrote: > > > > Is that normal or expected? > > The operation of REPLACE is defined here: > > https://www.sqlite.org/mark/lang_conflict.html?the+REPLACE+al*+current+row#mark So the plural in "deletes pre-exist

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread Simon Slavin
On 12 Jul 2016, at 1:26pm, Clemens Ladisch wrote: > An INSERT OR UPDATE (or MERGE) statement does not exist in SQLite. > > Just try the UPDATE, and if the number of affected rows is zero, do the > INSERT. I prefer to do INSERT OR IGNORE ... UPDATE ... That way you do not have to count the af

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread Richard Hipp
On 7/12/16, Dominique Devienne wrote: > > Is that normal or expected? The operation of REPLACE is defined here: https://www.sqlite.org/mark/lang_conflict.html?the+REPLACE+al*+current+row#mark -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread Clemens Ladisch
Dominique Devienne wrote: > sqlite> select * from t; > 1|one bis > 2|two > sqlite> insert or replace into t (name) values ('one bis'); > sqlite> select * from t; > 2|two > 3|one bis > > In the session above, we can see that an insert or replace w/o an id (the PK) > value, > results in the id chang

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread Dominique Devienne
On Tue, Jul 12, 2016 at 2:12 PM, Dominique Devienne wrote: > C:\Users\ddevienne>sqlite3 > SQLite version 3.10.2 2016-01-20 15:27:19 > Enter ".help" for usage hints. > Connected to a transient in-memory database. > Use ".open FILENAME" to reopen on a persistent database. > sqlite> create table t (

Re: [sqlite] INSERT OR REPLACE in a virtual table implementation....

2014-10-17 Thread dave
... > On 10/18/2014 01:07 AM, dave wrote: > > I have a virtual table implementation, and I would like to > use the INSERT OR > > REPLACE syntax to simplify actions for the user. In my > xUpdate method, for > > the case where insertion is occuring, > > ... > > on a virtual table, or something els

Re: [sqlite] INSERT OR REPLACE in a virtual table implementation....

2014-10-17 Thread Dan Kennedy
On 10/18/2014 01:07 AM, dave wrote: I have a virtual table implementation, and I would like to use the INSERT OR REPLACE syntax to simplify actions for the user. In my xUpdate method, for the case where insertion is occuring, else if ( argc > 1 && SQLITE_NULL == sqlite3_value_type ( argv[0] ) )

Re: [sqlite] INSERT OR REPLACE

2014-04-21 Thread Richard Hipp
On Mon, Apr 21, 2014 at 1:38 PM, Simon Slavin wrote: > > On 21 Apr 2014, at 6:18pm, Richard Hipp wrote: > > > SQLite does the right thing and enforces NOT NULL on PRIMARY KEY for the > > newer WITHOUT ROWID tables. But long ago there was a bug that prevented > > enforcement NOT NULL on PRIMARY

Re: [sqlite] INSERT OR REPLACE

2014-04-21 Thread Simon Slavin
On 21 Apr 2014, at 6:18pm, Richard Hipp wrote: > SQLite does the right thing and enforces NOT NULL on PRIMARY KEY for the > newer WITHOUT ROWID tables. But long ago there was a bug that prevented > enforcement NOT NULL on PRIMARY KEY of ordinary tables and by the time the > bug was discovered w

Re: [sqlite] INSERT OR REPLACE

2014-04-21 Thread Richard Hipp
On Mon, Apr 21, 2014 at 1:15 PM, Neville Dastur wrote: > > On 21 Apr 2014, at 18:13, Andy Goth wrote: > > > On 4/21/2014 6:04 AM, Richard Hipp wrote: > >> On Mon, Apr 21, 2014 at 6:18 AM, Neville Dastur wrote: > >>> Google only showed up that UNIQUE needs to be added regardless of the > >>> colum

Re: [sqlite] INSERT OR REPLACE

2014-04-21 Thread Neville Dastur
On 21 Apr 2014, at 18:13, Andy Goth wrote: > On 4/21/2014 6:04 AM, Richard Hipp wrote: >> On Mon, Apr 21, 2014 at 6:18 AM, Neville Dastur wrote: >>> Google only showed up that UNIQUE needs to be added regardless of the >>> column being a PRIMARY KEY. >> >> Google is wrong. The UNIQUE is superf

Re: [sqlite] INSERT OR REPLACE

2014-04-21 Thread Andy Goth
On 4/21/2014 6:04 AM, Richard Hipp wrote: On Mon, Apr 21, 2014 at 6:18 AM, Neville Dastur wrote: Google only showed up that UNIQUE needs to be added regardless of the column being a PRIMARY KEY. Google is wrong. The UNIQUE is superfluous. PRIMARY KEY always implies UNIQUE. Always. PRIMARY

Re: [sqlite] INSERT OR REPLACE

2014-04-21 Thread Neville Dastur
Sorry, Simon’s post help track down the problem. SELECT hospitals_id, length(hospitals_id), typeof(hospitals_id) FROM hospitals; Showed nulls were being inserted into hospitals_id. Bitten by the documented NULLs aren’t unique bug/feature thing. And thank you for clarifying about UNIQUE Nevil

Re: [sqlite] INSERT OR REPLACE

2014-04-21 Thread Richard Hipp
On Mon, Apr 21, 2014 at 6:18 AM, Neville Dastur wrote: > I seem to have a strange problem. > > I am using the INSERT OR REPLACE INTO syntax on a Sqlite DB running in iOS > simulator 7.1 (not exactly sure which sqlite version that is) > > I have a column defined as hospitals_id TEXT PRIMARY KEY UNI

Re: [sqlite] INSERT OR REPLACE

2014-04-21 Thread Simon Slavin
On 21 Apr 2014, at 11:18am, Neville Dastur wrote: > I have a column defined as hospitals_id TEXT PRIMARY KEY UNIQUE which stores > a GUID. Hence the text primary key. When I do an INSERT OR REPLACE the rows > are duplicated. I want to check that these keys really are duplicates and don't just

Re: [sqlite] INSERT or REPLACE alternatives

2013-09-14 Thread Keith Medcalf
> Alright, so I made the modifications as so to the Categories table: > > CREATE TABLE [Categories] ( > [CatID] INTEGER PRIMARY KEY AUTOINCREMENT, > [Name] CHAR COLLATE NOCASE); > > CREATE UNIQUE INDEX [idxCatName] ON [Categories] ([Name] COLLATE > NOCASE); > > Does this make more sense? >

Re: [sqlite] INSERT or REPLACE alternatives

2013-09-14 Thread Stephen Chrzanowski
Alright, so I made the modifications as so to the Categories table: CREATE TABLE [Categories] ( [CatID] INTEGER PRIMARY KEY AUTOINCREMENT, [Name] CHAR COLLATE NOCASE); CREATE UNIQUE INDEX [idxCatName] ON [Categories] ([Name] COLLATE NOCASE); Does this make more sense? I have a row with Name

Re: [sqlite] INSERT or REPLACE alternatives

2013-09-14 Thread Keith Medcalf
> As for the case, I wanted to make absolutely certain that when I update > based on text and not an ID, the most recent form of the text is put > into play. > I didn't want to have the software add Motherboard and > MotherBoard as two distinct rows, so I went all out on making sure that > everyt

Re: [sqlite] INSERT or REPLACE alternatives

2013-09-14 Thread Stephen Chrzanowski
Correction... ... *"... so the database hasn't had the TABLE created to support the feature yet."* On Sat, Sep 14, 2013 at 12:02 PM, Stephen Chrzanowski wrote: > Thanks for the input. I'll look into it. Looks cleaner than what I've > got now. > > As for the case, I wanted to make absolutely ce

Re: [sqlite] INSERT or REPLACE alternatives

2013-09-14 Thread Stephen Chrzanowski
Thanks for the input. I'll look into it. Looks cleaner than what I've got now. As for the case, I wanted to make absolutely certain that when I update based on text and not an ID, the most recent form of the text is put into play. I didn't want to have the software add Motherboard and MotherBoa

Re: [sqlite] INSERT or REPLACE alternatives

2013-09-14 Thread Keith Medcalf
Use insert or ignore: Insert or ignore into table values (list of bound values); Select idfield from table where naturalkeyfield = [refererence to appropriate bound value]; And execute both statements together. You will be returned the id. Example: Create table data ( Id integer primary key,

Re: [sqlite] INSERT OR REPLACE

2012-12-16 Thread Peter Haworth
Thanks SImon. Pretty much what I expected, just checking if I was missing something obvious. Pete lcSQL Software On Sun, Dec 16, 2012 at 9:00 AM, wrote: > I think you 'should not use'. You can do an UPDATE and see whether it > updated anything using the sqlite3_changes

Re: [sqlite] INSERT OR REPLACE

2012-12-15 Thread Simon Slavin
On 15 Dec 2012, at 6:26pm, Peter Haworth wrote: > If I understand the docs correctly, the REPLACE part of an INSERT OR > REPLACE command deletes a row if a UNIQUE constraint occurs and inserts a > new row in its place. Correct. f that commend decides a REPLACE is needed the original row will

Re: [sqlite] INSERT OR REPLACE

2012-03-12 Thread Alek Paunov
On 12.03.2012 16:02, Christian Smith wrote: I've had a similar problem in the past, and solved it by using a pre-insert trigger to do the desired update. Thus, the insert/update from above becomes just an insert (or ignore), with an implied update in the trigger, which appears to be sematically

Re: [sqlite] INSERT OR REPLACE

2012-03-12 Thread Nico Williams
On Mon, Mar 12, 2012 at 9:02 AM, Christian Smith wrote: > On Fri, Mar 09, 2012 at 09:49:22AM +1100, BareFeetWare wrote: >> I suggest only using "insert or replace" if you genuinely want to delete and >> replace with a new row. This is generally not hat you want if there are any >> foreign keys.

Re: [sqlite] INSERT OR REPLACE

2012-03-12 Thread Christian Smith
On Fri, Mar 09, 2012 at 09:49:22AM +1100, BareFeetWare wrote: > I suggest only using "insert or replace" if you genuinely want to delete and > replace with a new row. This is generally not hat you want if there are any > foreign keys. > > Only use "insert or ignore" if you are inserting exactly

Re: [sqlite] INSERT OR REPLACE

2012-03-09 Thread Alek Paunov
On 09.03.2012 17:39, Nico Williams wrote: Perhaps a Google summer of code project or something? Perhaps. Unfortunately not :-(. Google people have made a mistake in the past - looking for formal criteria to guarantee the openness of the initiative they included the rule that mentoring organ

Re: [sqlite] INSERT OR REPLACE

2012-03-09 Thread Nico Williams
On Fri, Mar 9, 2012 at 6:05 AM, Ryan Johnson wrote: > Don't forget stored procedures. I didn't need to pollute the language with procedural extensions in order to make my case, which is why I didn't mention stored procedures :) I figured using stored procs in my argument was going to detract fr

Re: [sqlite] INSERT OR REPLACE

2012-03-09 Thread Marc L. Allen
> That's why you don't make a DBMS (SQL) do the job of a programming > language. Use your programming language to to retrieve the values you > need to make your calculations. Then use your programming language to > figure out the new values and execute the UPDATE commands needed to > make the cha

Re: [sqlite] INSERT OR REPLACE

2012-03-09 Thread Ryan Johnson
On 08/03/2012 6:15 PM, Nico Williams wrote: On Thu, Mar 8, 2012 at 4:37 PM, Simon Slavin wrote: That's why you don't make a DBMS (SQL) do the job of a programming language. Use your programming language to to retrieve the values you need to make your calculations. Then use your programming

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Mario Becroft
Alek Paunov writes: > So maybe it's worth to give it a try ... Is there someone else, which > is interested to work on VDBE dump/load to assembler representation? > Once these base tools are available, maybe other people would reuse > bytecode instrumentation for other purposes also ;-) I don't

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Alek Paunov
On 09.03.2012 02:22, Nico Williams wrote: On Thu, Mar 8, 2012 at 5:57 PM, Alek Paunov wrote: Let suppose hypothetical function: asm(sql): returns VDBE assembler code for the sql parameter (like 'explain' but with full instruction attributes) I am curious, Is it evaluable (to proper VDBE code)

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Nico Williams
On Thu, Mar 8, 2012 at 5:57 PM, Alek Paunov wrote: > Let suppose hypothetical function: > > asm(sql): returns VDBE assembler code for the sql parameter (like 'explain' > but with full instruction attributes) > > I am curious, Is it evaluable (to proper VDBE code): > > asm(update with complex join)

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Alek Paunov
Hi List, On 09.03.2012 01:15, Nico Williams wrote: SQL was not, originally, a Turing complete language (unless one were to consider cross self joins of large tables for driving iteration as good enough), but nowadays it pretty much is, therefore it is a programming language. The language suppo

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Nico Williams
On Thu, Mar 8, 2012 at 4:37 PM, Simon Slavin wrote: > That's why you don't make a DBMS (SQL) do the job of a programming language.   > Use your programming language to to retrieve the values you need to make your calculations.  Then use your programming language to figure out the new values and ex

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread BareFeetWare
I suggest only using "insert or replace" if you genuinely want to delete and replace with a new row. This is generally not hat you want if there are any foreign keys. Only use "insert or ignore" if you are inserting exactly the same row as what might already be there. Otherwise use a combinati

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Simon Slavin
On 8 Mar 2012, at 7:43pm, Marc L. Allen wrote: >>> What happens if the intermediate delete breaks a foreign key >>> constraint? And does it happen if the insert restores the foreign key? >> >> The constraint stops the DELETE, and the operation fails. Just like >> you were worried about. So i

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Nico Williams
On Thu, Mar 8, 2012 at 1:52 PM, Pavel Ivanov wrote: >> So, please.. add INSERT OR UPDATE.  I'd ask that INSERT OR REPLACE be >> modified to do an UPDATE to the record if the UNIQUE Constraint is violated >> instead of the delete, but that would break existing applications. >> >> Wasn't that the

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Marc L. Allen
> No, because INSERT OR REPLACE can delete several rows and insert one > row instead of that. This kind of operation cannot be covered by UPDATE > in any way. I hadn't thought of that.. I suppose if two independent unique indexes had a constraint violation by the same record, it would delete two

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Pavel Ivanov
> So, please.. add INSERT OR UPDATE.  I'd ask that INSERT OR REPLACE be > modified to do an UPDATE to the record if the UNIQUE Constraint is violated > instead of the delete, but that would break existing applications. > > Wasn't that the original intent of INSERT OR REPLACE? No, because INSERT

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Marc L. Allen
> > What happens if the intermediate delete breaks a foreign key > constraint? And does it happen if the insert restores the foreign key? > > The constraint stops the DELETE, and the operation fails. Just like > you were worried about. So instead of doing > > INSERT OR REPLACE ... > > you do

Re: [sqlite] INSERT OR REPLACE

2012-03-08 Thread Simon Slavin
On 8 Mar 2012, at 6:39pm, Marc L. Allen wrote: > What happens if the intermediate delete breaks a foreign key constraint? And > does it happen if the insert restores the foreign key? The constraint stops the DELETE, and the operation fails. Just like you were worried about. So instead of d

Re: [sqlite] INSERT OR Replace Help

2010-03-25 Thread jose isaias cabrera
"P Kishor" wrote... > In any case, for OP's purpose, and esp. since he seems to be inserting > numbers as strings, as implied by the quoted numbers, he might benefit > from > > CREATE TABLE test ( > t1 TEXT, > t2 TEXT, > t3 TEXT, > t4 TEXT, > PRIMARY KEY(t1, t2) > ); > > I don't know if INSER

Re: [sqlite] INSERT OR Replace Help

2010-03-25 Thread Igor Tandetnik
P Kishor wrote: > With regards to having a PK on a column with no affinity, I guess > things will just default to strings, no? No. Just as with any other column with no affinity, no conversions will take place. Thus, 1 and '1' will be considered distinct, and 20 will sort before '1'. > In any c

Re: [sqlite] INSERT OR Replace Help

2010-03-25 Thread P Kishor
On Thu, Mar 25, 2010 at 5:06 PM, Igor Tandetnik wrote: > P Kishor wrote: >> On Thu, Mar 25, 2010 at 4:44 PM, jose isaias cabrera >> wrote: >>> Create table test (t1 primary key, t2 secundary key, t3, t4); >> >> >> I am pretty certain that SQLite has no idea what 't1 primary key' >> means. > > No

Re: [sqlite] INSERT OR Replace Help

2010-03-25 Thread Igor Tandetnik
P Kishor wrote: > On Thu, Mar 25, 2010 at 4:44 PM, jose isaias cabrera > wrote: >> Create table test (t1 primary key, t2 secundary key, t3, t4); > > > I am pretty certain that SQLite has no idea what 't1 primary key' > means. No, it's perfectly OK. It means a column with no affinity, which als

Re: [sqlite] INSERT OR Replace Help

2010-03-25 Thread P Kishor
On Thu, Mar 25, 2010 at 4:44 PM, jose isaias cabrera wrote: > Create table test (t1 primary key, t2 secundary key, t3, t4); I am pretty certain that SQLite has no idea what 't1 primary key' means. Perhaps you meant to say 't1 integer primary key'? I am completely certain that SQLite has no idea

Re: [sqlite] insert or replace

2009-01-08 Thread Jay A. Kreibich
On Thu, Jan 08, 2009 at 06:30:38AM -0800, liron.levy10 scratched on the wall: > > i am trying to use the "insert or replace" query command , and "insert" is > the command who executed always even though the query is alredy exist. and > the right command to use is "replace" command > someone know

Re: [sqlite] insert or replace

2009-01-08 Thread S B
Do you have a primary key on the table you're running the insert or replace statement on? I'm assuming you meant the record already exists. SB On Thu, Jan 8, 2009 at 9:30 AM, liron.levy10 wrote: > > i am trying to use the "insert or replace" query command , and "insert" is > the command who ex

Re: [sqlite] INSERT OR REPLACE without new rowid

2007-05-08 Thread Trey Mack
;c', then testing if (sqlite3_changes() == 0), if so, INSERT the data, which is likely faster (thanks for the idea Igor). I think the SQL standard is going to adopt the MERGE command for this type of operation, but I'm not sure.. is anyone in the know? It's in ORACLE now, surely e

RE: [sqlite] INSERT OR REPLACE without new rowid

2007-05-08 Thread B V, Phanisekhar
Hi Trey, Even I was looking for something like this. But I don't think SQL allows you to do this. I didn't get what u said about INSERT OR REPLACE looks good. Regards, Phani -Original Message- From: Trey Mack [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 24, 2007 9:11 PM To: sqlite-u

Re: [sqlite] INSERT or REPLACE

2007-03-22 Thread P Kishor
Oracle has MERGE. Search for UPSERT and SQL Server. On 3/22/07, Doug <[EMAIL PROTECTED]> wrote: The conflict algorithms in SQLite are brilliant. It's exactly what I've needed, and after working with SQLite for so long, I had forgotten that it wasn't part of the SQL standard (as far as I know--b

Re: [sqlite] insert or replace - bug or intended behaviour?

2004-08-25 Thread Christian Smith
On Wed, 25 Aug 2004, Daniel Franke wrote: >Nevertheless, it'd vote for an addition to the manual, e.g. >"When a UNIQUE constraint violation occurs, the pre-existing rows that are >causing the constraint violation are removed prior to inserting or updating >the current row [, i.e. any data the pre-

Re: [sqlite] insert or replace - bug or intended behaviour?

2004-08-25 Thread Daniel Franke
Am Dienstag, 24. August 2004 20:53 schrieb Kurt Welgehausen: > > there might be a bug in the replace-conflict handler of sqlite-2.8.15... > > What you are seeing is the correct behavior; the entire row > is replaced. Perhaps you are confusing insert with update. Kurt, you would be absolutely rig

Re: [sqlite] insert or replace - bug or intended behaviour?

2004-08-24 Thread Kurt Welgehausen
> there might be a bug in the replace-conflict handler of sqlite-2.8.15... What you are seeing is the correct behavior; the entire row is replaced. Perhaps you are confusing insert with update. Regards