1,284 questions
0
votes
1
answer
197
views
supabase_flutter does not allow anon UPSERT with "new row violates row-level security policy" error even though anon RLS policies seem to be set right
I have a Supabase table named "users" that contains a unique key column (text) named "id_rc1" and another column named "version" (text), among other fields all of which ...
0
votes
1
answer
34
views
Upsert! Operation Throws "A table can't contain duplicate column names" Error
I have a base table A and a result table B in DolphinDB. Table B was initially empty and is used to store calculated results based on table A. When trying to insert the calculated results into table B,...
2
votes
1
answer
297
views
Return the value changed by an update without a trigger
Postgres has a great RETURNING clause for INSERT, DELETE and UPDATE...and it's made me a bit greedy. In a few cases, what I'd like to get is not only the current value, but the previous value:
UPDATE ...
2
votes
1
answer
113
views
MongoDB C# Driver: Update only provided fields, including setting some fields to null
I am using MongoDB with C# (MongoDB.Driver) and I want to update only the fields provided in my API model. My current approach works for updating values, but I cannot set a field (string, number, or ...
0
votes
0
answers
88
views
If a record already exists, update current record and insert new record [duplicate]
If a value already exists in a table, how do I update the current record and add the new record as a new row?
This is the current upsert query:
UPDATE d
SET d.[AccountId] = S.[Account_Number],
...
12
votes
2
answers
10k
views
Snowflake MERGE update/insert all columns
Does Snowflake support updating/inserting all columns with a syntax like UPDATE * or INSERT *
MERGE INTO events
USING updates
ON events.eventId = updates.eventId
WHEN MATCHED THEN
...
8
votes
4
answers
7k
views
Is LockModeType.PESSIMISTIC_WRITE sufficient for an UPSERT in JPA?
I've read this article on JPA concurrency, but either I am too thick or it is not explicit enough.
I am looking to do a database-controlled atomic update-if-found-else-insert operation (an UPSERT).
...
3
votes
2
answers
11k
views
Inserting records into SQL Server, how to update on conflict?
I have a statement that looks like this:
Insert into table (value1, value2, value3)
Values (%s, %s, %s)
Could I do something where it will attempt to insert, but on conflict update value2 and value3 ...
0
votes
2
answers
9k
views
Upsert function in TypeORM
I am trying to implement upsert functionality to avoid redundant data into the database. Mentioned below is the schema that I have created.
@Entity({ name: 'tokens' })
export class Token {
@...
0
votes
0
answers
107
views
How to avoid a full table scan with Iceberg "merge"
I am currently running into an issue with using Athena's iceberg "merge" where it ends up scanning the entire source + target table.
For example, I have a source table and a target table.
...
11
votes
3
answers
7k
views
How to bulk upsert with Django
bulk_create with ignore_conflicts=True insert new records only and doesn't update existing one.
bulk_update updates only existing records and doesn't insert new one.
Now I see only one variant to ...
383
votes
11
answers
245k
views
How to use RETURNING with ON CONFLICT in PostgreSQL?
I have the following UPSERT in PostgreSQL 9.5:
INSERT INTO chats ("user", "contact", "name")
VALUES ($1, $2, $3),
($2, $1, NULL)
ON CONFLICT("user", "contact") DO ...
179
votes
14
answers
211k
views
Use multiple conflict_target in ON CONFLICT clause
I have two separately unique columns in a table: col1, col2. Both have a unique index (col1 is unique and so is col2).
I need INSERT ... ON CONFLICT ... DO UPDATE syntax, and update other columns in ...
0
votes
0
answers
58
views
Apply Merge from Bronze DLT Table into Silver DLT Table with some light cleaning? (Traditional Upsert style)
I am trying to create a DLT pipeline and this is my first time doing it. What is the best possible way to satisfy my following requirements. I am fully aware that the path I am choosing may not be ...
0
votes
0
answers
80
views
AWS Glue - Dynamic Frames - UPSERT to MongoDB
Code Snippet :
def write_alert_summary_df_docdb(alert_df,database,collection):
try:
update_df = DynamicFrame.fromDF(alert_df.select("*",lit("update").alias(&...
5
votes
1
answer
8k
views
Insert or update (upsert) multiple objects using ORM session
I'm trying to upsert using SQLAlchemy. There's no upsert in SQL but SQLAlchemy provides this. The same thing I'm trying to perform with SQLAlchemy ORM session. My code:
from sqlalchemy.orm import ...
0
votes
2
answers
103
views
Troubleshooting Optional ID Handling in Prisma Upsert Operations
I'm encountering a challenge with my Prisma objects and could use some insights. I've defined the following Prisma objects, and my expectation is to optionally pass an id and perform an upsert. ...
2
votes
1
answer
144
views
sybase merge query with where clause in insert or skip the insert on condition
I have a table with account_number, amount , last_updated_time.
I wrote a merge query as below
MERGE INTO account AS target
USING (SELECT ?,?,?)
AS SRC(account_number, amount , last_updated_time)
ON ...
1
vote
0
answers
718
views
What are the best way to load incremental data into database using Spark?
I have tried multiple ways to incremental load (upsert) into the Postgres database (RDS) using Spark (with Glue Job) but did not find satisfactory performance.
I have tried like this:
1. Delete the ...
1
vote
1
answer
562
views
ADF upsert error locating key column in the interim table
I have a pipeline with copy data task where I upsert some data from On-Prem SQL into Synapse. The setup is such that I first establish the list of tables and then, in ForEach, I dynamically set Key ...
2
votes
1
answer
5k
views
Mybatis - Returning ID on Upsert
I have a statement configured that looks something like this (paraphrasing here, don't have the actual code in front of me):
<insert id="createRecord" parameterType="map">
INSERT INTO MYTABLE ...
2
votes
1
answer
166
views
Postgres / SQL pattern for atomic SELECT and UPDATE or INSERT within a transaction
I have a simple scenario, where I want to atomically read and modify the state of a row. But the row may not exist yet.
For this example, I use the user_group_membership table:
user_id (pk) | group_id ...
0
votes
2
answers
272
views
Can't figure out a query to upsert collection into a tablr
I want to insert or update rows into my models table. But can't figure out the query.
SmStudentAttendance This is my model.
$students is my collection.
I have put the collection fields in arrays.
...
0
votes
2
answers
104
views
Adding column in upsert using on_conflict_do_update
I'm trying to add a timestamp column, updated_at, in the updates when doing a upsert using on_conflict_do_update. Below is my current implementation but encounter the below error when running at the ...
7
votes
2
answers
756
views
SQLite UPSERT and get insert or updated rowid
I have a table storing directory paths (Dirs). These directory rows are referenced by a Files table, using the directory's rowid as a foreign key. When re-indexing directories/files there is the need ...