2

I am creating a copy job with Azure Data Factory (v2) from our on-premise Oracle database to our Azure Data Lake. Ideally, this copy job is set up as a delta-load, where only the information from the last day is considered.

To do so, we want to filter the column "load_time", which is of the format datetime, with dynamic content functionality of Azure Data Factory.

The dummy query would be:

SELECT sales.* FROM schema.sales sales WHERE sales.load_time >= {everything from one hour ago}

When enriching this query with dynamic content, we have something like

SELECT sales.* FROM schema.sales sales WHERE sales.load_time >= addHours(utcnow(), -1, format='yyyy-MM-dd HH:mm:ss')

However, we continue to run into an error:

ORA-00904:"ADDHOURS": invalid identifier

Does anyone have any experience / insight in what is going wrong here?

Thanks

EDIT-1: We aim to use the expressions from the Dynamic Content in Azure Data Factory, such as "addHours" to set the datetime limit.

3 Answers 3

3

Looks like the issue is with Dynamic expression which is used to form the required query.

Please try updating your dynamic expression as below in your ADF pipeline activity to form a valid query.

I have defined a pipeline parameter named SingleQuotes of type string and value = ' (single quote) - This is required to form a valid where condition like "WHERE sales.load_time >='2020-03-16 20:04:04' "

Dynamic Expression:

@concat('SELECT sales.* FROM schema.sales sales WHERE sales.load_time >=', pipeline().parameters.singleQuotes, formatDateTime(addHours(utcnow(), -1), 'yyyy-MM-dd HH:mm:ss'), pipeline().parameters.singleQuotes)

This dynamic expression will generate a SQL query as below: (I have tried this in T-SQL)

"sqlReaderQuery": "SELECT sales.* FROM schema.sales sales WHERE sales.load_time >='2020-03-16 20:04:04'"

Hope this helps.

Sign up to request clarification or add additional context in comments.

3 Comments

Do I understand your solution correctly that @CAST is needed to convert the Dynamic Content to a string, so that the Oracle DB understands the query?
Thank you for your help! We were able to progress and found a new error, namely: "ORA-01861: literal does not match format string". Any leads on this?
We were able to solve the error by using a TO_CHAR around "sales.load_time" in the WHERE statement.
1

I believe the ADDHOURS that is in use is from Oracle .Net C# function. It's not part of the Oracle functions. You could build your own function in PL/SQL which mimics the same function but the better solution is to rewrite the where clause. Something like

WHERE sales.load_time >= sysdate - interval '1' hour

1 Comment

The ADDHOURS is function from Azure Dynamic Content Documentation, which we are trying to use in the Azure Data Factory pipeline.
0

I had the same issue I have sorted it out via the following method:

  1. Create a Set variable activity (Let's say the name - X)

enter image description here

@formatDateTime('2022-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss')
  1. Write the following Code to pipeline expression builder:

    @{concat('select * from Table where Column1=''','A',''' AND TO_CHAR(Date, ''', 'YYYY-MM-DD HH24:MI:SS',''') >= ''', variables('X'),'''')}

This will do the trick!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.