0

我正在尝试根据日期从 oracle 中进行简单的拉动。最后,我需要这个查询是动态的,因此在 ADF 中使用 @concat() 函数。为简单起见,我想在 ADF 中使用 concat 运行以下 oracle 查询。

由于 oracle 需要单引号,我试图通过使用两个单引号来转义它。

甲骨文查询:

select * from schema.customer where updated > to_date('06/25/2019','MM/DD/YYYY')

这是我的 ADF 文本:

@concat('select * from iris.iris_customer where updated > to_date(','''06/25/2019''','''MM/DD/YYYY''',');')

我使用 to_date 是因为我收到了“无效月份”错误,并认为我可以解决它。这是我得到的错误:

{ "errorCode": "2200", "message": "'Source' 端发生故障。ErrorCode=UserErrorUnclassifiedError,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Odbc Operation Failed.,Source=Microsoft。 DataTransfer.ClientLibrary.Odbc.OdbcConnector,''Type=System.Data.Odbc.OdbcException,Message=ERROR [22008] [Microsoft][ODBC Oracle Wire Protocol driver][Oracle]ORA-01843: not a valid month,Source= msora28.dll,'", "failureType": "UserError", "target": "copy_to_adl" }

4

2 回答 2

3

您应该使用''转义单引号。

我的例子:@{concat('DELETE FROM MyTable WHERE [ColumnDate] LIKE','''',pipeline().parameters.processYear,pipeline().parameters.processMonth,'%','''')}

于 2019-06-27T09:01:45.360 回答
0

您还可以在 ADF 数据流的表达式构建器中使用此 SQL 语法来转义单引号:

“SELECT * FROM myTable WHERE Id = {$myVar} AND Gender = 'M'”

于 2022-01-20T14:40:09.450 回答