ADF SQL 在日期周围使用单引号进行查询
ADF SQL Query with single quotes around dates
我正在尝试根据日期从 oracle 中进行简单的拉取。最终,我需要这个查询是动态的,因此在 ADF 中使用 @concat() 函数。为简单起见,我想 运行 ADF 中带有 concat 的以下 oracle 查询。
由于 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,因为我遇到了 'not a valid month' 错误,我认为我可以解决它。这是我收到的错误:
{
"errorCode": "2200",
"message": "Failure happened on 'Source' side. 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" }
你应该使用 ''
来转义单引号。
我的例子:@{concat('DELETE FROM MyTable WHERE [ColumnDate] LIKE','''',pipeline().parameters.processYear,pipeline().parameters.processMonth,'%','''')}
您还可以在 ADF 数据流中的表达式构建器中使用此 SQL 语法来转义单引号:
"SELECT * 来自 myTable,其中 Id = {$myVar} 和性别 = 'M'"
我正在尝试根据日期从 oracle 中进行简单的拉取。最终,我需要这个查询是动态的,因此在 ADF 中使用 @concat() 函数。为简单起见,我想 运行 ADF 中带有 concat 的以下 oracle 查询。
由于 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,因为我遇到了 'not a valid month' 错误,我认为我可以解决它。这是我收到的错误:
{ "errorCode": "2200", "message": "Failure happened on 'Source' side. 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" }
你应该使用 ''
来转义单引号。
我的例子:@{concat('DELETE FROM MyTable WHERE [ColumnDate] LIKE','''',pipeline().parameters.processYear,pipeline().parameters.processMonth,'%','''')}
您还可以在 ADF 数据流中的表达式构建器中使用此 SQL 语法来转义单引号:
"SELECT * 来自 myTable,其中 Id = {$myVar} 和性别 = 'M'"