upsert

PostgreSQL Upsert with a WHERE clause

夙愿已清 提交于 2020-01-24 17:44:45
问题 I am trying to migrate an Oracle merge query to PostgreSql. As described in this article, Postgres UPSERT syntax supports a "where clause" to identify conditions of conflict. Unfortunately, that webpage does not provide an example with the "where clause". I tried searching for it elsewhere but could not find it. Hence this question. Following the same example in the above given webpage, here is an example setup: CREATE TABLE customers ( customer_id serial PRIMARY KEY, name VARCHAR UNIQUE,

Can SOLR perform an UPSERT?

。_饼干妹妹 提交于 2020-01-21 13:39:46
问题 I've been attempting to do the equivalent of an UPSERT (insert or update if already exists) in solr. I only know what does not work and the solr/lucene documentation I have read has not been helpful. Here's what I have tried: curl 'localhost:8983/solr/update?commit=true' -H 'Content-type:application/json' -d '[{"id":"1","name":{"set":"steve"}}]' {"responseHeader":{"status":409,"QTime":2},"error":{"msg":"Document not found for update. id=1","code":409}} I do up to 50 updates in one request and

Can SOLR perform an UPSERT?

帅比萌擦擦* 提交于 2020-01-21 13:37:40
问题 I've been attempting to do the equivalent of an UPSERT (insert or update if already exists) in solr. I only know what does not work and the solr/lucene documentation I have read has not been helpful. Here's what I have tried: curl 'localhost:8983/solr/update?commit=true' -H 'Content-type:application/json' -d '[{"id":"1","name":{"set":"steve"}}]' {"responseHeader":{"status":409,"QTime":2},"error":{"msg":"Document not found for update. id=1","code":409}} I do up to 50 updates in one request and

How to update all columns with INSERT … ON CONFLICT …?

99封情书 提交于 2020-01-21 06:27:17
问题 I have a table with a single primary key. When I attempt to do an insert there may be a conflict caused by trying to insert a row with an existing key. I want to allow the insert to update all columns? Is there any easy syntax for this? I am trying to let it "upsert" all columns. I am using PostgreSQL 9.5.5. 回答1: The UPDATE syntax requires to explicitly name target columns. Possible reasons to avoid that: You have many columns and just want to shorten the syntax. You do not know column names

Can INSERT […] ON CONFLICT be used for foreign key violations?

为君一笑 提交于 2020-01-19 06:08:38
问题 Given => select * from referenced; referenced_id | name ---------------+------- 1 | one 2 | two 3 | three and => select * from entries; entry_id | referenced_id | name ----------+---------------+------------------ 1 | 3 | references three where referenced_id and entry_id are primary keys. I want an insert statement for entries that skips insertion if either the entry_id already exists or the referenced item does not exist. The first is easily done: INSERT INTO entries VALUES (1, 2,

Can INSERT […] ON CONFLICT be used for foreign key violations?

雨燕双飞 提交于 2020-01-19 06:05:16
问题 Given => select * from referenced; referenced_id | name ---------------+------- 1 | one 2 | two 3 | three and => select * from entries; entry_id | referenced_id | name ----------+---------------+------------------ 1 | 3 | references three where referenced_id and entry_id are primary keys. I want an insert statement for entries that skips insertion if either the entry_id already exists or the referenced item does not exist. The first is easily done: INSERT INTO entries VALUES (1, 2,

Can INSERT […] ON CONFLICT be used for foreign key violations?

杀马特。学长 韩版系。学妹 提交于 2020-01-19 06:04:46
问题 Given => select * from referenced; referenced_id | name ---------------+------- 1 | one 2 | two 3 | three and => select * from entries; entry_id | referenced_id | name ----------+---------------+------------------ 1 | 3 | references three where referenced_id and entry_id are primary keys. I want an insert statement for entries that skips insertion if either the entry_id already exists or the referenced item does not exist. The first is easily done: INSERT INTO entries VALUES (1, 2,

Can't UPDATE a large image size that was INSERTed in the database in asp.net

谁说胖子不能爱 提交于 2020-01-16 04:59:15
问题 Here is the problem, when I insert an image (let's call it Data A) which is 1.32MB, it will be inserted successfully. But if I will insert again Data A(but it will update now because i used UPSERT, see my code), it will not be updated and it will result to connection time out. But when i insert another data (Data B) which is only 4KB, it will also be inserted successfully and if I will insert again into it(which is update), it will be updated successfully. What can I do? I cannot understand

Error in my SQL statement (UPSERT)

穿精又带淫゛_ 提交于 2020-01-16 04:08:07
问题 I'm trying to do an UPSERT (since that's what it appears to be called) and I'm getting an error: Microsoft JET Database Engine error '80040e14' Syntax error (missing operator) in query expression ... UPDATE myTable SET Field1='10', Field2='11' WHERE Date = #06/05/2013# IF @@ROWCOUNT = 0 BEGIN INSERT INTO myTable (Field1, Field2) VALUES (10, 11) END 回答1: Your code is using T-SQL (SQL Server) syntax that Access SQL does not understand. The VBA equivalent would be: Dim cdb As DAO.Database Set

IDocumentClient.UpsertDocumentAsync doesn't update, it inserts duplicated ids

谁说我不能喝 提交于 2020-01-13 20:26:13
问题 I have a VS2017 solution in C#, and I'm using IDocumentClient.UpsertDocumentAsync to Upsert some documents into my cosmosdb documentdb collection. But I noticed it's actually creating new documents with the same id while there already is a document in the collection with that id. Now after upserting a new document with the same id the query result looks something like this: select * from c where c.id = "aaaa-bbbb-cccc" [ { "id": "aaaa-bbbb-cccc", "firstname": "john", "lastname": "doe" }, {