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
4 answers

Question about inserting/updating rows with SQL Server (ASP.NET MVC)

I have a very big table with a lot of rows, every row has stats for every user for certain days. And obviously I don't have any stats for future. So to update the stats I use UPDATE Stats SET Visits=@val WHERE ... a lot of conditions ... AND…
Alex
  • 34,581
  • 26
  • 91
  • 135
0
votes
0 answers

Upsert multiple records into salesforce with external ids

I am upserting records using php tool kit into salesforce. Salesforce have limit of 28000 inserts in a day. So to avoid this what i want to do is to insert 150 recors into one array and then inseet into salesforce. I this way 150 records will hit…
0
votes
1 answer

Mongo c# driver UpdateBuilder AddToSet not update existing item

I am trying to update an array item in a BsonDocument using the UpdateBuilder.AddToSet method. However, the method always insert a new copy of the item in the array instaed of updating the existing. Here's my object : public class Document …
Raphaël
  • 427
  • 5
  • 14
0
votes
1 answer

How to optimize MERGE using multiple column index

I'm new to MERGE and an index novice so bear with me... I have a stored procedure that builds a #changes temp table, UPDATEs a prod_tbl table based on #changes, then INSERTs the before and after values into auto_update_log table that is quickly…
jreed121
  • 2,067
  • 4
  • 34
  • 57
0
votes
3 answers

Dynamic upsert in postgresql

I have this upsert function that allows me to modify the fill_rate column of a row. CREATE FUNCTION upsert_fillrate_alarming(integer, boolean) RETURNS VOID AS ' DECLARE num ALIAS FOR $1; dat ALIAS FOR $2; BEGIN LOOP -- First…
Daniel
  • 617
  • 1
  • 7
  • 10
0
votes
3 answers

How do I upsert a mongo (or spring-mongo) document containing a list

I'm trying determine if there is a way using spring-mongodb (or even using the mongo java API), to upsert a document containing a list such that the elements of the list are always a union of the values upserted. Suppose I have the following…
0
votes
2 answers

merge statement - upsert - performing unique test in source table as well

I need some help with SQL Server merge statement. I am using version 2008. I have two tables table1 and table2 with 3 column in each table: name, age, lastname. I want to do little variant of Upsert from table2 to table1. If record exists in table…
keeping_it_simple
  • 439
  • 1
  • 11
  • 31
0
votes
1 answer

Upsert using insert... on duplicate key update

There are many tutorials out there but i haven't been able to make it work somehow. I am trying to update my table if data in all but except on column matches the data i'm inserting through a form. I am using php as the scripting language and mysql…
user3508140
  • 285
  • 2
  • 18
0
votes
0 answers

FK Violation using EF Upsert logic with internal object retrieved from DB

so I am implementing EF in my project. In my unit testing I have come accross an issue I cannot seem to figure out on my own... I have... class Employee{ Guid uid name: "Foo"; Department: dempartmentObj; } class department{ Guid uid name:…
asuppa
  • 571
  • 1
  • 11
  • 27
0
votes
2 answers

Why does UPSERT does a DELETE and INSERT instead of UPDATE (SQLite)

I was wondering why, when using Peewee at least, UPSERT does DELETE and INSERT rather than UPDATE when the entry is already in the table? Is there any reason for which it would be preferable to "DELETE then INSERT" rather than "try UPDATE otherwise…
bsuire
  • 1,383
  • 2
  • 18
  • 27
0
votes
0 answers

What's the best way to handle insert unique, okay to overwrite?

I want to maintain a Collection of geographical info for IP addresses. var IpAddressSchema = new Schema({ ip: { type: String, unique: true }, geo: Object }, { strict: true }); IPs should be unique. And if an IP already exists, it…
WendyMcF
  • 23
  • 1
  • 4
0
votes
1 answer

Upsert hash in mongodb. Remove unused keys

From the Mongo documentation: If you specify multiple field-value pairs, $set will update or create each field. I have a mongoid document like this: class MyCounter include Mongoid::Document field :date, type: Date field :properties,…
dcarneiro
  • 7,060
  • 11
  • 51
  • 74
0
votes
1 answer

Upsert failing to insert

I have the following SQL BEGIN DECLARE @UpdateCount int EXEC (@UpdateSQL) SET @UpdateCount = @@RowCount IF (@UpdateCount < 1) BEGIN EXEC (@InsertSQL) END END SET NOCOUNT ON; This lives inside a trigger however it isn't working as I would…
Alec.
  • 5,371
  • 5
  • 34
  • 69
0
votes
2 answers

MySQL "UPSERT" and delete not affected rows

I have a table in MySQL that is updated every night with a cron task. Every row is altered, because I'm getting the data from a XLS file and have to update all values. At first my question was if it worth updating each row or on the other hand just…
Alberto
  • 367
  • 3
  • 11
0
votes
1 answer

Trying to get an UPSERT working on a set of data using dapper

I'm trying to get an upsert working on a collection of IDs (not the primary key - that's an identity int column) on a table using dapper. This doesn't need to be a dapper function, just including in case that helps. I'm wondering if it's possible…
someguy0005
  • 125
  • 2
  • 12