假设我有一个简单的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作为源吗?
答案 0 :(得分:1)
支持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