string to SQL statement

Hello Everyone,

i have four input as string
1.Init_SQL—this have hard code value(Select * from)
2.Filter1
3.Filter2
4.Order_By

and i want my output as a sql statement like
(select * from xyz where(filter1value=" " and Filter2value=’ '), order_by value),
if any value of input is null that will not be the part of the output

Thanks

Hi Rohit,

As your SQL is dynamic, i suggest you prepare the SQL statement in IS service and then supply the input to “Dynamic SQL”

To have better performance on SQL, you can have IF-ELSE-THAN (should get on google) and use this as an input to CUSTOM SQL (prepared statement).

Hi ,
Please do the below.

1)use a branch step for each values and if it is not null ,then create a string for that particular filter and do a varaible susbitution like ColumnName=%filterValue%

Repeat the step for each input and use makeString service to create AND clause.
Then ,create where clause by using concat service .
Then pass this string as a input to your dynamic SQL service.

eg : select * from table ${where} . (you will pass where statement created in above steps here.

Thanks,
Sathya

Adding to Satya response
Its always a good practice to specify column names