问题描述
假设我有一个简单的XML文件源,已将其映射到sql Server数据库中的相应接收器。
<Date Date="2020-03-13Z">
<Identification>
<Identifier>Maverick</Identifier>
</Identification>
<Pilot HomeAirport="New York">
<AirportICAOCode>USA</AirportICAOCode>
</Pilot>
</Date>
然后是模式
CREATE TABLE pilots
identifier VARCHAR(20),ICAO_code VARCHAR(3)
)
我在sql服务器数据库中创建了一个存储过程,该存储过程接受用户定义的表类型pilots_type的输入,该表类型对应于上述架构,以正确地合并我的数据。
{
"errorCode": "2200","message": "ErrorCode=UserErrorInvalidpluginType,'Type=Microsoft.DataTransfer.Common.Shared.PluginNotRegisteredException,Message=Invalid type 'XmlFormat' is provided in 'format'. Please correct the type in payload and retry.,Source=Microsoft.DataTransfer.ClientLibrary,'","failureType": "UserError","target": "Sink XML","details": []
}
查看图片
这里的源是包含XML的Blob。
毕竟不支持将XML作为源吗?
解决方法
支持XML作为源。
我已经根据您的示例xml文件和sql表成功进行了相同的测试。
- 我创建了一个名为
ct_pilot_type
的表类型:
CREATE TYPE ct_pilot_type AS TABLE(
identifier nvarchar(MAX),ICAO_code nvarchar(MAX)
)
- 我创建了名为
spUpsertPolit
的存储过程:
CREATE PROCEDURE spUpsertPolit
@polit ct_pilot_type READONLY
AS
BEGIN
MERGE [dbo].[pilot_airports] AS target_sqldb
USING @polit AS source_tblstg
ON (target_sqldb.identifier = source_tblstg.identifier)
WHEN MATCHED THEN
UPDATE SET
identifier = source_tblstg.identifier,ICAO_code = source_tblstg.ICAO_code
WHEN NOT MATCHED THEN
INSERT (
identifier,ICAO_code
)
VALUES (
source_tblstg.identifier,source_tblstg.ICAO_code
);
END
- 我在“复制”活动中设置了接收器:
- 我设置了映射: