Я сделал это с помощью foreach и выполнил dll-операцию, но когда попробуйте вставить o uptdate, строка выдает exeption, однако с использованием значений int.Как слияние сервера sql с mule?
Exeption: `стек Исключение:
1. Invalid column name 'Carlos'. (com.microsoft.sqlserver.jdbc.SQLServerException)
com.microsoft.sqlserver.jdbc.SQLServerException:217 (null)
2. Invalid column name 'Carlos'. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: LinkedHashMap (org.mule.api.MessagingException)
org.mule.module.db.internal.processor.AbstractDbMessageProcessor:93 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'Carlos'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1635)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:865)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:762)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:6276)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1793)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:184)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:159)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(SQLServerStatement.java:2198)
at org.mule.module.db.internal.domain.autogeneratedkey.NoAutoGeneratedKeyStrategy.executeUpdate(NoAutoGeneratedKeyStrategy.java:59)
at org.mule.module.db.internal.domain.executor.UpdateExecutor.doExecuteQuery(UpdateExecutor.java:43)
at org.mule.module.db.internal.domain.executor.UpdateExecutor.doExecuteQuery(UpdateExecutor.java:37)
at org.mule.module.db.internal.domain.executor.AbstractSingleQueryExecutor.execute(AbstractSingleQueryExecutor.java:38)
at org.mule.module.db.internal.processor.ExecuteDdlMessageProcessor.doExecuteQuery(ExecuteDdlMessageProcessor.java:53)
at org.mule.module.db.internal.processor.AbstractSingleQueryDbMessageProcessor.executeQuery(AbstractSingleQueryDbMessageProcessor.java:42)
at org.mule.module.db.internal.processor.AbstractDbMessageProcessor.process(AbstractDbMessageProcessor.java:66)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.routing.outbound.AbstractMessageSequenceSplitter.processParts(AbstractMessageSequenceSplitter.java:129)
at org.mule.routing.outbound.AbstractMessageSequenceSplitter.process(AbstractMessageSequenceSplitter.java:59)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.routing.Foreach.process(Foreach.java:94)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.interceptor.AbstractEnvelopeInterceptor.processBlocking(AbstractEnvelopeInterceptor.java:58)
at org.mule.processor.AbstractRequestResponseMessageProcessor.process(AbstractRequestResponseMessageProcessor.java:47)
at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:123)
at o...
********************************************************************************
`
'Carlos' имеет значение от полезной нагрузки.
Это DLL
BEGIN MERGE [FP].[Profile] AS DESTINO USING (SELECT #[payload.ID]) AS
FUENTE (ID) ON (DESTINO.ID=FUENTE.ID) WHEN MATCHED THEN UPDATE SET
[UserId]= #[payload.UserId] WHEN NOT MATCHED THEN INSERT
(ID,UserId,ExternalId,FirstName) VALUES (#[payload.ID],#
[payload.UserId],#[payload.ExternalId],#[payload.FirstName]); END
XML-поток:
<flow name="insertprofilesindwFlow">
<file:inbound-endpoint path="C:\Users\LBonaventura\Documents\MuleFilesFromDB" responseTimeout="10000" doc:name="Read the file with the profiles" moveToDirectory="C:\Users\LBonaventura\Documents\MuleFilesFromDB" pollingFrequency="864000000"/>
<dw:transform-message metadata:id="57e39ab0-6c79-4118-a57e-fe6561a04e9b" doc:name="Transform Message to map">
<dw:input-payload doc:sample="list_csv_1.csv"/>
<dw:set-payload><![CDATA[%dw 1.0 %output application/java ---payload map ((payload01 , indexOfPayload01) -> {
ID: payload01.ID,
ExternalId: payload01.ID as :string,
UserId: payload01.UserId,
FirstName: payload01.FirstName,
LastName: payload01.LastName,
(DateOfBirth: payload01.DateOfBirth as :string) when payload01.DateOfBirth != "",
(DateOfBirth: null) when payload01.DateOfBirth=="",
(Gender:"M") when payload01.Gender=="1",
(Gender:"F") when payload01.Gender=="0",
(Gender:null) when payload01.Gender=="",
AllowTracking: payload01.AllowTracking,
Email: payload01.AlertEmail,
MainProfile: payload01.Main,
Active: payload01.Active as :boolean,
CreatedOn: payload01.DateAdded as :string,
UpdatedOn: payload01.DateUpdated as :string,
LanguageIso: "ESP",
Deleted: false})]]></dw:set-payload>
</dw:transform-message>
<foreach doc:name="For Each Profile">
<db:execute-ddl config-ref="FOX_DW_DATABASE_CONFIGURATION" doc:name="Upsert in the Database">
<db:dynamic-query><![CDATA[BEGIN MERGE [FP].[Profile] AS DESTINO
USING (SELECT #[payload.ID]) AS FUENTE (ID)
ON (DESTINO.ID=FUENTE.ID)
WHEN MATCHED THEN
UPDATE SET
[UserId]= #[payload.UserId],
[FirstName]=#[payload.FirstName]
WHEN NOT MATCHED THEN
INSERT
(ID,UserId,ExternalId,[FirstName])
VALUES
(#[payload.ID],#[payload.UserId],#[payload.ExternalId],#[payload.FirstName]); END]]></db:dynamic-query>
</db:execute-ddl>
</foreach>
</flow>
здесь операция:. > НАЧАТЬ MERGE [FP] [Профиль] КАК Destino \t ИСПОЛЬЗОВАНИЕ (SELECT # [payload.ID]) А.С. FUENTE (ID) \t ВКЛ (DESTINO.ID = FUENTE.ID) \t когда подобрано ТОГДА \t \t UPDATE SET \t \t \t \t [UserId] = # [payload.UserId] \t \t \t \t \t \t КОГДА НЕ MATCHED ТОГДА \t \t \t ВСТАВИТЬ \t \t \t (ID, идентификатор пользователя, ExternalId, FirstName) \t ЗНАЧЕНИЯ (# [payload.ID], # [payload.UserId], # [полезной нагрузки. ExternalId], # [payload.FirstName]); END –
Можете ли вы опубликовать полный поток xml? Это может помочь –
Вы пытались написать запрос без квадратных скобок вокруг столбца, например, MATCHED THEN UPDATE SET UserId = –