Reputation: 393
I am trying to run a Pre SQl script before inserting data using ADF. My Pre SQL Script contains data flow parameter. Please note the parameter value below.
parameter1 = one of the column of excel sheet (suppose value is 'XY')
PFB the query
"DELETE FROM ABC WHERE col_name = {$parameter1}" -- Output :: XY
"DELETE FROM ABC WHERE col_name = '{$parameter1}'" -- Output :: XY I checked above using a derived column activity.
When I run below query
"DELETE FROM ABC WHERE col_name ='{$parameter1}'" -- Error : column operands are not allowed in literal expressions
If I try below
concat('DELETE FROM ABC WHERE col_name =',toString('''+ toString(byPath('$parameter1'))+ ''') ) Result I see in Derived Column DELETE FROM ABC WHERE col_name ='XY' But When I add this to Pre SQL script I am seeing below error Column functions are not allowed in constant expressions
Need suggestion on usage of parameters in Pre SQL script with some examples. Appreciate your time and help.
Upvotes: 1
Views: 3635
Reputation: 6043
ADF not allow us to pass a Column functions result to the expression. So we need to add a Lookup activity outside the dataflow. Then pass the output value of Lookup activity to your dataflow parameters via expression.
Add the source dataset to your Lookup activity.
This is my output of my Lookup activity.
So I pass the value to my dataflow parameter via expression @activity('Lookup1').output.firstRow.name
.
In the sink of my dataflow, I add "DELETE FROM emp WHERE name = '{$parameter1}'"
to Pre SQL scripts. ADF will execute DELETE FROM emp WHERE name = 'Tim'
.
This works well in my side.
Upvotes: 3