Is there any way to perform the equivalent of an INSERT OR UPDATE statement?
I have something like this:
CREATE TABLE t1 (id INTEGER PRIMARY KEY, value INTEGER);
CREATE TABLE t2 (parent INTEGER REFERENCES t1 ON DELETE CASCADE, child
INTEGER REFERENCES t1);
INSERT INTO t1 VALUES(1,100);
INSERT INT
On 02/07/2011, at 4:54 AM, KeithB wrote:
> Is there any way to perform the equivalent of an INSERT OR UPDATE statement?
>
> I have something like this:
>
> CREATE TABLE t1 (id INTEGER PRIMARY KEY, value INTEGER);
> CREATE TABLE t2 (parent INTEGER REFERENCES t1 ON DELETE CASCADE, child
> INTEGER
Or do an update and if no records are modified then do an insert.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
On 1 Jul 2011, at 7:54pm, KeithB wrote:
> Is there any way to perform the equivalent of an INSERT OR UPDATE statement?
>
> I have something like this:
>
> CREATE TABLE t1 (id INTEGER PRIMARY KEY, value INTEGER);
> CREATE TABLE t2 (parent INTEGER REFERENCES t1 ON DELETE CASCADE, child
> INTEGER
Is there any way to perform the equivalent of an INSERT OR UPDATE statement?
I have something like this:
CREATE TABLE t1 (id INTEGER PRIMARY KEY, value INTEGER);
CREATE TABLE t2 (parent INTEGER REFERENCES t1 ON DELETE CASCADE, child
INTEGER REFERENCES t1);
INSERT INTO t1 VALUES(1,100);
INSERT INT
On 10/11/2010, at 7:19 PM, Michele Pradella wrote:
> In-Reply-To: <4cda28ea.5030...@gmail.com>
Firstly, please start a post to this mail list as a new message, not a reply to
a previous unrelated message. That's known as "thread hijacking" and confuses
discussions.
> Hi all, I have to INSERT
On 10 Nov 2010, at 8:19am, Michele Pradella wrote:
> Hi all, I have to INSERT a row in a DB but I have first to check if the
> Key I'm inserting already exist.
> Now I'm doing a "SELECT count..." first to check if the key exist and
> then INSERT or UPDATE records.
> Do you know if there's a be
Michele Pradella wrote:
> Hi all, I have to INSERT a row in a DB but I have first to check if the
> Key I'm inserting already exist.
> Now I'm doing a "SELECT count..." first to check if the key exist and
> then INSERT or UPDATE records.
> Do you know if there's a better or faster way to do that?
Hi all, I have to INSERT a row in a DB but I have first to check if the
Key I'm inserting already exist.
Now I'm doing a "SELECT count..." first to check if the key exist and
then INSERT or UPDATE records.
Do you know if there's a better or faster way to do that?
Perhaps with an ON CONFLICT
> 2. I suggest that you're better off doing the logic entirely in SQL, rather
> than application code, for the sake of portability, data integrity and speed.
I'd say this is a very bad advice for the developer using SQLite.
First of all "insert or ignore" and "insert or replace" are not
portable
On Tue, 19 Oct 2010 10:54:13 +1100
BareFeetWare wrote:
> -- alternatively you could do this, which will update the existing
> row, if exists, or insert a new one if it doesn't:
>
> update users set "name" = 'Joe C', "type" = 4, where "id" = 1;
> insert or ignore into users ("id", "type", "name")
On 19/10/2010, at 8:10 AM, NSRT Mail account. wrote:
> I would use the update if I knew the entry already existed. In my application
> however, it doesn't know if the entry already exists. I was looking for
> something to replace MySQL's ON DUPLICATE KEY UPDATE.
>
> I modified my application to
12 matches
Mail list logo