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
-1
votes
1 answer

Get information what has changed during Postgres UPSERT query

During an UPSERT query on PostgreSQL it is not obvious which entries of a table has changed (inserted or updated). Query: First add an unique constraint for the businessKey: alter table public."test_table" add constraint "bk_constraint" unique…
leon22
  • 5,280
  • 19
  • 62
  • 100
-1
votes
2 answers

Column name is ambiguous on UPSERT action

I am trying to run an UPSERT query string on a postgres db - insert into business_data_test (select * from business_data_tmp) on conflict(phone_number) do update set average_expense=(average_expense*expense_count +…
Anurag-Sharma
  • 4,278
  • 5
  • 27
  • 42
-1
votes
1 answer

Upsert or update SQL records based on some columns using Pandas and SQL Alchemy?

I'd like to see if anyone can help with this, not even sure if it can be done. I have a SQL table that looks like this: GUID Timestamp Asset Channel Value Units …
ortunoa
  • 345
  • 4
  • 11
-1
votes
3 answers

How do you define an upsert (if exists update else insert) or even an update using graphql?

EDIT: I'm going to give the SQL equivalents here because its the easiest way I can convey what I'm trying to find an equivalent to. The schema for a person is id (system assigned clustered PK, probably a guid, doesnt really matter for this) …
StingyJack
  • 19,041
  • 10
  • 63
  • 122
-1
votes
1 answer

with sql how can i insert data but if it's already exists update data

I want to add it - if exists update else insert! so that insert is working but i want to only insert new value and if thing already here i want to update it. my code here only inserts data no metter what BEGIN DECLARE das int; SELECT dasaxeleba.id…
-1
votes
1 answer

How do I update/upsert a document/Data in Mongoose? Passport MongoDB, Express, AngularJS, Nodejs

var LocalStrategy = require('passport-local').Strategy; // load up the user model var User = require('../app/models/user'); // save the user newUser.save(function(err) { if (err) throw err; return done(null, newUser); });
-1
votes
1 answer

Insert in Merge not working in Oracle

I am new to Oracle. I have a table in Oracle which has 4 columns Period, Open_Flag,Creation_Dt,Updated_By. The Period column is the Primary key of the table. I have created a proc which will check the value of period from input parameter in the…
Meen
  • 119
  • 3
  • 15
-1
votes
1 answer

Update/Insert to a table in SQL

I have two tables: TableA column0 int identity, Key1 varchar(50), Key2 varchar(50), Column3 varchar(50) TableB Key1 varchar(50), Key2 varchar(50), Column3 varchar(50) Now I have to insert/update into TableB from TableA depending on the Key1 and…
that_me123
  • 61
  • 3
  • 10
-1
votes
1 answer

Upsert with .net sqladapter

Dim sSelect As String = _ "SELECT * FROM Contacts" & _ " WHERE DataSetID = @DataSetID AND ID >= @FirstID AND ID <= @LastID ORDER BY ID" Dim dsDBFiles As New DataSet() Dim cmd As New SqlClient.SqlCommand(sSelect,…
Prabu
  • 4,097
  • 5
  • 45
  • 66
-2
votes
2 answers

Does DynamoDB's UpdateItemCommand have an "update only" mode?

I have some TypeScript code in a project that does a number of native DynamoDB update operations: import { nativeDocumentClient, nativeDynamo } from '../utils/aws'; // snipped code // updatedProducts is of type `{ id: string; siteId: string;…
halfer
  • 19,824
  • 17
  • 99
  • 186
-2
votes
3 answers

Using a if condition in an insert SQL Server

I have the following statement in my code INSERT INTO #TProductSales (ProductID, StockQTY, ETA1) VALUES (@ProductID, @StockQTY, @ETA1) I want to do something like: IF @ProductID exists THEN UPDATE #TProductSales ELSE INSERT INTO…
Hloni Lydron
  • 1
  • 1
  • 1
-2
votes
1 answer

Merge Statement inserting duplicate rows?

For the eternity that I have been spending time on this, I can't seem to find the cause as to why my MERGE statement inserts duplicate rows. Here are my tables. TABLE INVENTORY ProductID | ProductName | ProductCode | Quantity | …
Saudate
  • 431
  • 2
  • 8
  • 14
1 2 3
81
82