将SQL server合并代码转换为等效的Postgresql代码
如何将SQL server的合并转换为等效的postgresql代码: 我是SQL Server新手,不知道合并的行为将SQL server合并代码转换为等效的Postgresql代码,sql,sql-server,database,postgresql,migration,Sql,Sql Server,Database,Postgresql,Migration,如何将SQL server的合并转换为等效的postgresql代码: 我是SQL Server新手,不知道合并的行为 merge PortfolioAssetClassBenchmark_Subset as t using @inputBenchmark as s on t.PortfolioId = @PortfolioId and t.StartDate = s.F_STARTDATE when matched and isnull(s.F_BENCHMARK, 0) != 0
merge PortfolioAssetClassBenchmark_Subset as t
using @inputBenchmark as s
on t.PortfolioId = @PortfolioId and t.StartDate = s.F_STARTDATE
when matched and isnull(s.F_BENCHMARK, 0) != 0 and t.AssetClassBenchmarkId != s.F_BENCHMARK then
update set
t.AssetClassBenchmarkId = s.F_BENCHMARK
when matched and isnull(s.F_BENCHMARK, 0) = 0 then
delete
when not matched by target and isnull(s.F_BENCHMARK, 0) != 0 then
insert (PortfolioId, StartDate, AssetClassBenchmarkId)
values (@PortfolioId, s.F_STARTDATE, s.F_BENCHMARK)
when not matched by source and @clearExisting != 0 then
delete
output inserted.AssetClassBenchmarkId [InsertedAssetClassBenchmarkId]
, inserted.StartDate [InsertedStartDate]
, deleted.AssetClassBenchmarkId [DeletedAssetClassBenchmarkId]
, deleted.StartDate [DeletedStartDate]
into @tmp
欢迎来到SO。到目前为止你试过什么?请检查我正在使用Postgresql 12,此版本不再支持合并。我知道的唯一替代方法是插入conflict@swapnilsolanki . . . 示例数据、所需结果和逻辑解释将有所帮助。@GordonLinoff我只想知道在postgresql中复制相同数据时可能使用的语法