Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将SQL server合并代码转换为等效的Postgresql代码_Sql_Sql Server_Database_Postgresql_Migration - Fatal编程技术网

将SQL server合并代码转换为等效的Postgresql代码

将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

如何将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 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中复制相同数据时可能使用的语法