On Sun, Aug 20, 2017 at 05:17:16PM +, Wout Mertens wrote:
> Oh wow, I didn't know about ON CONFLICT, thanks!
>
> Unfortunately the behavior on UPDATE (actually INSERT OR REPLACE in my
> case) is not the desired behavior, it removes the row with the same k but
> different id.
PostgreSQL has so
lite> select * from demo;
> --EQP-- 0,0,0,SCAN TABLE demo
> id|k|otherstuff
> 1|30|Four-Mississippi
>
> sqlite>
>
> -Original Message-
> From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org]
> On Behalf Of R Smith
> Sent: Friday, August
8 PM
To: sqlite-users@mailinglists.sqlite.org
Subject: Re: [sqlite] Enforcing uniqueness from multiple indexes
On 2017/08/18 6:08 PM, R Smith wrote:
>
> Isn't this what conflict clauses on constraints are for?
>
Apologies, I usually add the test-case scripts in case anyone else wish
to test it or sim
On 2017/08/18 6:08 PM, R Smith wrote:
Isn't this what conflict clauses on constraints are for?
Apologies, I usually add the test-case scripts in case anyone else wish
to test it or similar, the case in question herewith added below:
-- SQLite version 3.17.0 [ Release: 2017-02-13 ] on
On 2017/08/18 1:47 PM, Richard Hipp wrote:
On 8/18/17, Wout Mertens wrote:
So, bottom line, is there a way to insert or replace a row so that first
the id constraint is observed (replacing a previous row with the same id),
and then the k constraint is verified (failing to replace if k is alrea
An INSERT OR UPDATE sure would be nice. What i often do in cases like this
is: UPDATE .. WHERE; INSERT .. SELECT .. WHERE NOT EXISTS (SELECT ..);.
That's two statements -- if that's a problem, then you should use D. R.
Hipp's trigger-based solution.
___
The UNIQUE will either do nothing, or will erase existing lines if a
trigger is forgotten. So not having the UNIQUE seems safer.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sql
On 8/18/17, Gerry Snyder wrote:
> Should it be :
>
> CREATE UNIQUE INDEX ...
I don't think it matters in this case. The trigger is also enforcing
uniqueness.
--
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sq
Should it be :
CREATE UNIQUE INDEX ...
Gerry Snyder
On Aug 18, 2017 4:47 AM, "Richard Hipp" wrote:
> On 8/18/17, Wout Mertens wrote:
> >
> > So, bottom line, is there a way to insert or replace a row so that first
> > the id constraint is observed (replacing a previous row with the same
> id
Splendid! Many thanks!
On Fri, Aug 18, 2017 at 1:47 PM Richard Hipp wrote:
> On 8/18/17, Wout Mertens wrote:
> >
> > So, bottom line, is there a way to insert or replace a row so that first
> > the id constraint is observed (replacing a previous row with the same
> id),
> > and then the k const
On 8/18/17, Wout Mertens wrote:
>
> So, bottom line, is there a way to insert or replace a row so that first
> the id constraint is observed (replacing a previous row with the same id),
> and then the k constraint is verified (failing to replace if k is already
> present in the table)?
CREATE TA
Hi,
I have the following problem: I have data where two independent values need
to be unique. I'm using one (id) as the primary key, and the other (let's
call it k) should just cause insertion or updating to fail if it already
exists in another row with a different id in the table.
Furthermore, I
12 matches
Mail list logo