sql-merge

Table Valued Parameter issue with MONO cs

橙三吉。 提交于 2019-12-04 05:52:06
问题 I have a simple code to create SqlParameter for Table Valued Type. The given code works just fine with .NET 4.0. Issue is with MONO CS (3.12.0), I cannot simply compile the same code in MONO. static SqlParameter GetDataTableParam(string _tableName, DataTable _dt) { SqlParameter tValue = new SqlParameter(); tValue.ParameterName = "@dr" + _tableName; //@drFactory tValue.SqlDbType = SqlDbType.Structured; tValue.Value = _dt; tValue.TypeName = string.Format("dbo.{0}Item", _tableName); //MONO CS is

SQL MERGE to remote (linked) server table

二次信任 提交于 2019-12-04 01:33:41
Is it possible to utilize the SQL MERGE function on a linked server's database table? The end goal is to synchronize the remote table with our local SQL server table. I’ve done some research online and couldn’t find any related information. If it is possible how would you setup the source and target statements? To reiterate the comment by @Mikael Eriksson, yes, you can. The target of a MERGE cannot be remote, but the source of a MERGE can be remote. So, if you can run the MERGE statement from your server in FL, then it is quite possible. For example, you could run something like this on your

When doing a MERGE in Oracle SQL, how can I update rows that aren't matched in the SOURCE?

随声附和 提交于 2019-12-03 11:45:16
问题 I have a main database and a report database, and I need to sync a table from main into report . However, when an item gets deleted in the main database, I only want to set an IsDeleted flag in the report database. What is an elegant way to do this? I'm currently using a MERGE statement, like this: MERGE INTO report.TEST target USING (SELECT * FROM main.TEST) source ON (target.ID = source.ID) WHEN MATCHED THEN UPDATE SET (target... = source...) WHEN NOT MATCHED THEN INSERT (...) VALUES

Oracle Merge vs Select then Insert or Update

梦想与她 提交于 2019-12-03 08:22:23
问题 What is faster? the Merge statement MERGE INTO table_name USING dual ON (row_id = 'some_id') WHEN MATCHED THEN UPDATE SET col_name = 'some_val' WHEN NOT MATCHED THEN INSERT (row_id, col_name) VALUES ('some_id', 'some_val') or querying a select statement then using an update or insert statement. SELECT * FROM table_name where row_id = 'some_id' if rowCount == 0 INSERT INTO table_name (row_id,col_name) VALUES ('some_id','some_val') else UPDATE table_name SET col_name='some_val' WHERE row_id=

When doing a MERGE in Oracle SQL, how can I update rows that aren't matched in the SOURCE?

落花浮王杯 提交于 2019-12-03 05:26:12
I have a main database and a report database, and I need to sync a table from main into report . However, when an item gets deleted in the main database, I only want to set an IsDeleted flag in the report database. What is an elegant way to do this? I'm currently using a MERGE statement, like this: MERGE INTO report.TEST target USING (SELECT * FROM main.TEST) source ON (target.ID = source.ID) WHEN MATCHED THEN UPDATE SET (target... = source...) WHEN NOT MATCHED THEN INSERT (...) VALUES (source...) ; The WHEN NOT MATCHED statement gives me all NEW values from main , but I also want to update

Oracle Merge vs Select then Insert or Update

喜夏-厌秋 提交于 2019-12-02 22:23:02
What is faster? the Merge statement MERGE INTO table_name USING dual ON (row_id = 'some_id') WHEN MATCHED THEN UPDATE SET col_name = 'some_val' WHEN NOT MATCHED THEN INSERT (row_id, col_name) VALUES ('some_id', 'some_val') or querying a select statement then using an update or insert statement. SELECT * FROM table_name where row_id = 'some_id' if rowCount == 0 INSERT INTO table_name (row_id,col_name) VALUES ('some_id','some_val') else UPDATE table_name SET col_name='some_val' WHERE row_id='some_id' The rule of thumb is, if you can do it in one SQL, it'll generally perform better than doing it

Table Valued Parameter issue with MONO cs

妖精的绣舞 提交于 2019-12-02 09:34:22
I have a simple code to create SqlParameter for Table Valued Type. The given code works just fine with .NET 4.0. Issue is with MONO CS (3.12.0), I cannot simply compile the same code in MONO. static SqlParameter GetDataTableParam(string _tableName, DataTable _dt) { SqlParameter tValue = new SqlParameter(); tValue.ParameterName = "@dr" + _tableName; //@drFactory tValue.SqlDbType = SqlDbType.Structured; tValue.Value = _dt; tValue.TypeName = string.Format("dbo.{0}Item", _tableName); //MONO CS is giving error at this line return tValue; } Mono compiler giving me this error: Error CS1061: Type

JdbcTemplate - Insert or update Oracle BLOB using SQL MERGE

↘锁芯ラ 提交于 2019-12-02 01:56:49
问题 Using JdbcTemplate I would like to call MERGE SQL statement which will insert a new record to the table or update if row with specific key already exists. The key part is that one of the column is of the Oracle BLOB type. Here is what I tried till now: Try 1. Sql statement: String sql = "" + "MERGE INTO file_thumbnails " + " USING (SELECT ? as file_c_id, ? as thumbnail_type, ? as thumbnail_image FROM DUAL) tmp " + " ON (file_thumbnails.file_c_id = tmp.file_c_id AND " + " file_thumbnails

JdbcTemplate - Insert or update Oracle BLOB using SQL MERGE

人盡茶涼 提交于 2019-12-01 23:21:15
Using JdbcTemplate I would like to call MERGE SQL statement which will insert a new record to the table or update if row with specific key already exists. The key part is that one of the column is of the Oracle BLOB type. Here is what I tried till now: Try 1. Sql statement: String sql = "" + "MERGE INTO file_thumbnails " + " USING (SELECT ? as file_c_id, ? as thumbnail_type, ? as thumbnail_image FROM DUAL) tmp " + " ON (file_thumbnails.file_c_id = tmp.file_c_id AND " + " file_thumbnails.thumbnail_type = tmp.thumbnail_type) " + " WHEN MATCHED THEN " + " UPDATE " + " SET thumbnail_image = tmp

MERGE table, do nothing when matched

落花浮王杯 提交于 2019-12-01 18:06:29
I have a table DOMAINS in 2 different schemas with columns ID , NAME , CODE , DESCRIPTION . For any NAME exist in new schema, it should use existing ID without any merge; for those new NAME records, it should insert with ID from old schema. MERGE INTO DOMAINS A USING (SELECT ID,NAME,CODE,DESCRIPTION FROM <Old Schema 6.1>.DOMAINS@DB_MIG_61_TO_74) B ON(A.NAME = B.NAME) WHEN MATCHED **<do nothing>** WHEN NOT MATCHED THEN INSERT(A.ID,A.NAME,A.CODE,A.DESCRIPTION) VALUES(B.ID,B.NAME,B.CODE,B.DESCRIPTION); How can i intepret the portion of do nothing in above query? For your case, no need to use the