存储过程返回标量值时,查找活动结果的表达式

时间:2019-06-06 10:53:55

标签: azure-data-factory azure-data-factory-2

我正在使用一个返回标量结果的Lookup活动,并且我想使用该结果通过concat表达式构建动态查询。但是,我收到一条错误消息,抱怨我的SQL查询格式不正确。这就是我建立查询的方式:

@concat('SELECT v.CscadaEventId as EventId, 
v.EndDate as EndDateUtc 
FROM v_cscadaevents v 
INNER JOIN cscadaevents e
ON e.cscadaeventId = v.CscadaEventId 
WHERE v.CscadaEventId IN(', activity('LookupUnfinishedAlarms').output.firstRow, ') AND e.EndDate IS NOT NULL;')

我希望它返回这样的查询:

SELECT v.CscadaEventId as EventId, 
v.EndDate as EndDateUtc 
FROM v_cscadaevents v 
INNER JOIN cscadaevents e
ON e.cscadaeventId = v.CscadaEventId WHERE v.CscadaEventId IN(2329390,2340616,2342078,2345857,2361240,2362088,2362574,2377062,2378594,2379357) AND e.EndDate IS NOT NULL;

我看到了一些示例,其中查找返回多列,并且正确的表达式为activity('LookupUnfinishedAlarms').output.firstRow.myColumnName,但是当查找活动返回标量值时(例如我的情况)呢?

这是到目前为止的完整错误:

  

您的SQL语法有错误;检查手册   对应于您的MariaDB服务器版本,以使用正确的语法   近   '\“输出\”:\“ 2329390,2340616,2342078,2345857,2361240,2362088,2362574,2377062,237859'   在线   6,Source = Microsoft.DataTransfer.Runtime.GenericOdbcConnectors,''类型= System.Data.Odbc.OdbcException,消息=错误   [42000] [Microsoft] [MariaDB]您的SQL语法错误;   检查与您的MariaDB服务器版本相对应的手册   在near使用正确的语法   '\“输出\”:\“ 2329390,2340616,2342078,2345857,2361240,2362088,2362574,2377062,237859'   在第6行,Source = MariaDBODBC_sb64.dll

1 个答案:

答案 0 :(得分:0)

好吧,仅作记录,我找到了解决方案。表达式必须为:

@concat('SELECT v.CscadaEventId as EventId, 
v.EndDate as EndDateUtc 
FROM v_cscadaevents v 
INNER JOIN cscadaevents e
ON e.cscadaeventId = v.CscadaEventId 
WHERE v.CscadaEventId IN(', activity('LookupUnfinishedAlarms').output.firstRow.output, ') AND e.EndDate IS NOT NULL;')

因此,默认列为output