使用BizTalk将Oracle数据库连接到SQL Server数据库

时间:2015-04-15 14:48:30

标签: sql-server stored-procedures biztalk

我很难创建存储过程,使用BizTalk将所选记录从Oracle数据库插入/更新到SQL Server数据库。

ALTER PROCEDURE [dbo].[uspInsertorUpdateINF]
@dp_id                char(32),
@dv_id                char(32),
@em_number            char(12),
@email                varchar(50),
@emergency_relation   char(32),
@option1              char(16),
@status               char(20),
@em_id                char(35),
@em_title             varchar(64),
@date_hired           datetime
AS
BEGIN
SET NOCOUNT ON;

MERGE [dbo].[em] AS [Targ]
USING (VALUES (@dp_id, @dv_id , @em_number, @email, @emergency_relation, @option1, @status, @em_id, @em_title, @date_hired))
AS [Sourc] (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired)  
  ON [Targ].em_id = [Sourc].em_id

  WHEN MATCHED THEN
  UPDATE 
     SET dp_id                 = [Sourc].dp_id,
         dv_id                 = [Sourc].dv_id,
         em_number             = [Sourc].em_number,
         email                 = [Sourc].email,
         emergency_relation    = [Sourc].emergency_relation,
         option1               = [Sourc].option1,
         status                = [Sourc].status,
         em_title              = [Sourc].em_title,
         date_hired            = [Sourc].date_hired

 WHEN NOT MATCHED BY TARGET THEN
  INSERT (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title,date_hired)
  VALUES ([Sourc].dp_id, [Sourc].dv_id, [Sourc].em_number, [Sourc].email, [Sourc].emergency_relation, [Sourc].option1, [Sourc].status, [Sourc].em_id, [Sourc].em_title, [Sourc].date_hired);

 END;

它只是将一条记录从Oracle DB插入SQL数据库。但是使用下面的行

选择整个记录集
<ns0:Select xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/View/VW_EMP30D"><ns0:COLUMN_NAMES>*</ns0:COLUMN_NAMES><ns0:FILTER></ns0:FILTER></ns0:Select>

我该怎么做才能将整套记录插入/更新到SQL数据库中。

1 个答案:

答案 0 :(得分:2)

好吧,你的存储过程只需要一组(实际上是行)参数,所以,是的,它只会更新一行。

您有两种选择:

  1. 将此存储过程用作WCF SQL Composite操作的一部分,您可以将每个Oracle结果映射到此SP的单个实例。
  2. 使用表值参数作为存储过程参数。
  3. 这些维基文章包含每个程序的样本:

    http://social.technet.microsoft.com/wiki/contents/articles/26279.biztalk-streamlining-wcf-sql-and-oracle-messaging-only-and-other-patterns.aspx

    http://social.technet.microsoft.com/wiki/contents/articles/24803.biztalk-server-sql-patterns-for-polling-and-batch-retreive.aspx