Questions tagged [upsert]

UPSERT is a combination of UPDATE and INSERT, typically used in relational databases.

UPSERT refers to types of statements (usually database statements) that INSERT an item (record) to a resource (table in a database) where, if the item already exists, it will update the existing item with the fields provided. The term UPSERT is an amalgamation of UPDATE and INSERT and is common slang among database developers.

1227 questions
0
votes
1 answer

Can mongodb "upsert" in this way?

I know that in conventional upsert operation of mongodb, if a document exists, mongodb will perform update, otherwise it will do insert. However what I want is: if a document exists, mongodb just leave it unchanged, otherwise it will do insert. Of…
user2384994
  • 1,759
  • 4
  • 24
  • 29
0
votes
1 answer

oracle upsert with conditional update

I want to insert a row in a DB based on following codition if table t has doesnot not have row with key X: insert into t mystuff.. else if update t set mystuff... where mykey=X if existingversion < NewVersion I know that normal merge…
user93796
  • 18,749
  • 31
  • 94
  • 150
0
votes
0 answers

UPSERT (insert or update) on a table with compound primary key

I have the following table structure 'category_id', 'int(11)', 'PRI' 'page_id', 'int(11)', 'PRI' 'current_week_visits', 'int(11)' I keep updating the current week visits daily on this table and I would like to insert a row if (app_id, page_id) is…
vasa
  • 787
  • 8
  • 21
0
votes
0 answers

MongoDB upsert operation blocks inconsistently (with syncdelay set to 0)

There is a database with 9 million rows, with 3 million distinct entities. Such a database is loaded everyday into MongoDB using perl driver. It runs smoothly on the first load. However from the second, third, etc. the process is really slowed down.…
Sai
  • 461
  • 7
  • 25
0
votes
1 answer

Helping converting an upsert statement into merge statement sql server

i don't understand well how to use the merge statement, i need to translate the following into the equivalent merge statement. Is merge faster then update/insert? ALTER PROCEDURE [dbo].[IOUUS] @a VARCHAR(50), @b VARCHAR(50), @c…
sparrows81
  • 431
  • 3
  • 6
  • 19
0
votes
1 answer

MongoDB C# driver upserting nested document

I have deeply embedded documents in MongoDB like so: [ { id : 1, stuff : [ { id : 1, morestuff: [ {id : 1, text : "foo"}, {id : 2, text : "boo"} …
Daniel Gruszczyk
  • 5,379
  • 8
  • 47
  • 86
0
votes
1 answer

MongoDB merge 2 very similar collections. Existing documents - update, new documents - insert

I have 2 collections (A and B) with ~70,000 documents each. If I were to compare A and B, 95% of documents would be the same, only 5% would be different. Structure of each document is completely identical in both A and B. A is a constant collection,…
Victor S
  • 839
  • 1
  • 6
  • 3
0
votes
0 answers

concurrency issues while upserting and then reading the data from mongodb using mongoose

Hi I am trying to build an application which upserts data and fetches from the mongodb baser on the userid.This approach works fine for a single user.But when i try hitting for multiple users say 25 the data fetched seems to be null. Below is my…
Amanda G
  • 1,931
  • 10
  • 33
  • 43
0
votes
0 answers

Upserting subdocument in for loop

Not sure why this isn't working, I've tried a few different variations of syntax, but no go. I'm also unsure if having an update inside a for loop is a good idea. Basically I'm updating a user's inventory by passing an object that contains two…
0
votes
1 answer

Insert or update a row in SQLite

I found this answer but I'm not sure it does what I want to. It looks like it updates ALL rows in the table, where I only want to update one. My table is very simple: MacAddress | Name 1C-6F-65-C6-20-0B | …
ldam
  • 4,412
  • 6
  • 45
  • 76
0
votes
1 answer

MongoDB: upsert multiple fields based on multiple criteria

I am new to Mongo. I wanted to atomically upsert a document based on multiple criteria. The document looks like the following: {_id:..., hourOfTime:..., total:..., max:..., min:..., last:...} This is basically hourly aggregation for number of…
Nishant
  • 54,584
  • 13
  • 112
  • 127
0
votes
0 answers

Doing an upsert in mongo, can I specify a custom query for the "insert" case?

Possible Duplicate: Mongodb upsert only update selected fields, but insert all Say I have this: db.Person.update({ name: "Ignacio" }, { $inc: { age: 1 } }, { upsert: true }); It will load the person "Ignacio" and increase his age. What I need…
superiggy
  • 1,023
  • 8
  • 14
0
votes
1 answer

UPSERT statement in Postgres on a partitioned table

I have a partitioned table and an update function/trigger. when a row is updated, it first deletes the row and then inserts it into the proper partition. My question is that I am trying to do a statement similar to a MERGE in Oracle. I found…
0
votes
1 answer

Using SQL Server Merge from a string instead of a table

How can I create an Upsert functionality for a table with a composite key when sending the query via php? I have an order_items table whose key is both an order number and an item number. I then have an api to a store that returns an xml document…
Mike
  • 1,718
  • 3
  • 30
  • 58
0
votes
1 answer

Syntax errors when creating triggers

I know this question has been thrown here in various forms, but I have gone through them all and not able to get solution to my issue. I don't understand why I keep getting this language error on this script. I have approached it following two…
Shade
  • 31
  • 1
  • 2
  • 10