Questions tagged [sql-merge]

`SQL MERGE` statement allows us to insert new rows into table and update existing rows depending on given condition. Use this tag in addition to [tag:sql] to make question better categorized.

SQL MERGE statement allows us to insert new rows into table and update existing rows depending on given condition.

Examples of using MERGE statement:

Use this tag in addition to to make question better categorized.

324 questions
0
votes
0 answers

Do Parallel DML and APPEND hint with the MERGE (upsert) SQL make better performance for Oracle Pro*C Code?

I am having quite a large volume of data in my Oracle table. Through Oracle Pro*C code, I am trying to use host arrays for managing merge into DB table as per following example: merge into TBL_NM A using (select 1 from dual) B on (col1 =…
Dr. Debasish Jana
  • 6,980
  • 4
  • 30
  • 69
0
votes
0 answers

Oracle Pro*C Bulk Merge of records in C using host arrays degrading performance with increased volume

Using Oracle 11g Pro*C in C, I am using host arrays for managing bulk merge into DB table as per following example: merge into TBL_NM A using (select 1 from dual) B on (col1 = to_date(:v,'YYMMDD') and col2 = :v and col3 = :v and col4 = :v) when…
Dr. Debasish Jana
  • 6,980
  • 4
  • 30
  • 69
0
votes
2 answers

What controls the order of INSERT, UPDATE and DELETE operations in a SQL MERGE statement?

How does SQL Server's MERGE work? If there are multiple operations to be performed (INSERT,UPDATE,DELETE) then what controls the order in which these operations are carried out?
Queen
  • 11
  • 1
0
votes
0 answers

query optimization on merge statement

I am trying to update a very large table from an other table. The table i am trying to update is actually having millions of records. What I have done is here: merge into mo_moentity m using ( select * from d_cell3g_cminfo tt )n on ( m.motypeid=…
Aqeel Abbas
  • 159
  • 4
  • 13
0
votes
0 answers

How can I use SQL MERGE to insert if not exists, and SET a variable to the Id?

I have an Id column set by SEQUENCE Given a varchar I need to INSERT if there is not match, and return an Id. The Id will be either: The existing Id of the row with the matchine ItemName The new Id generated by the sequence because a row was…
Matthew
  • 10,244
  • 5
  • 49
  • 104
0
votes
0 answers

Merging table along with update a column which has comma sepated string

i have a table1 Option ID |option | PreRequisite ------------------------------------- 1 | India | null 2 | Japan | null 3 | China | null 4 | ABC | Q1|1,Q2|2 5 | DEF | Q1|1 6 | KLM | Q1|1 i have…
Ramveer Singh
  • 39
  • 1
  • 5
0
votes
2 answers

SQL - Merge trying to INSERT instead of UPDATE because of NULL columns

Hello and good day to everyone. I am trying to execute the following sequence on two tables table2 and table1. MERGE INTO table2 WITH (HOLDLOCK) AS target USING ( SELECT column1, MAX(AccessDate) AS AccessDate, …
Bogdan Pușcașu
  • 545
  • 2
  • 7
  • 21
0
votes
1 answer

Merge in H2 database

I am using H2 database's MERGE command but don't understand a part of its documentation. The troubling part being - If the table contains an auto-incremented key or identity column, and the row was updated, the generated key is set to 0; otherwise…
x-treme
  • 1,606
  • 2
  • 21
  • 39
0
votes
0 answers

SQL merge query?

I have merge query like below MERGE [dbo].[tablename] AS tpr USING @Tabletype AS spr ON tpr.[ee_typeid] = spr.[ee_typeid] WHEN MATCHED THEN UPDATE SET tpr.[name]=spr.[name], tpr.[modifiedon]=spr.[modifiedon], …
harshu288
  • 141
  • 1
  • 12
0
votes
1 answer

Using MERGE to delete data, or insert

From the UI I pass a datatable to a stored procedure. The type of that parameter is a user defined table field with the following structure Personkey int ComponentKey varchar This data needs to go into a table, and data that exists in the table but…
andrewb
  • 2,995
  • 7
  • 54
  • 95
0
votes
1 answer

Oracle: Invalid identifier

I am using the following query in oracle. However, it gives an error saying that "c.par" in line 5 is an invalid parameter. No idea why. The columns exist. I checked. I have been struggling with this for a long time. All I want to do is to merge one…
0
votes
2 answers

Merging two tables without duplicating

I need to merge two user tables to one without duplicates. for example : in my database i have tables en_user and kn_user and there are few users exists in both so i when i run an query to merge kn_user with en_user then unique users present in…
0
votes
1 answer

oracle sql multiple new rows merge in to a table

I need to insert new rows into an oracle(12c) SQL table only if they don't exists using java code It is possible that there will be more then 100 rows to check and insert ideally I would like to have one merge statement with multiple…
Panteleev Dima
  • 175
  • 2
  • 18
0
votes
0 answers

Merge the values of two tables from different SQL Servers with slow connection

I have two (linked) Microsoft SQL servers with basically the same setup but they differ in the content. Connection with servers is slow. Some tables contains lot of rows. Some records differ in the fields. Data on each servers match for 99% I need…
Timur Lemeshko
  • 2,747
  • 5
  • 27
  • 39
0
votes
1 answer

merge statement issue(mainly for update ) incase block

i was trying to insert certain data from one table(table1) to another table(table2) in a way like if data is existing just update the data or insert the data .But the problem now i am facing is,when i added a last condition like if first_name like…
peter
  • 8,158
  • 21
  • 66
  • 119