Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to add a "where" condition in toracleinput request

Hi everyone.

I'm a new one in Talend.

And I want to ask you , how to add a "where" condition in tOracleinput via tJava.

Regards.

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

 

    In the tjava component, you will have to provide basic if-else conditions to verify whether data is present for each column you are planning to compare. If the data is not present, populate the target context variable for each incoming column as empty string  else populate the context variable with inbound value.

 

    Once all parameters are checked, concatenate them and connect all the corresponding context variables in your tOracleinput component.

 

pseudo logic

 

context.where="where ";

if (var1_input is null) 

      {

        context.var1="";

       }

else 

      {

        context.var1= "table_name.col1="+var1_input;

      }

Similarly for next columns also... But please note that first column having not null should be prefixed with "where " and after that you need to use "and " to join the columns (you need to add logic here)

 

so final where clause will be:-

 

context.condition=context.where+context.var1+ context.and+context.var2...... etc.

 

Add this condition in the where clause of the tOracleinput.

 

"select * from employee "+ context.condition;

 

If the answer has helped you to resolve the issue, could you please mark the topic as solution provided?

 

Warm Regards,

 

Nikhil

 

 

View solution in original post

6 Replies
fdenis
Master
Master

can you define your job? what do you need exactly? tJava is not here for that!
Anonymous
Not applicable
Author

Here is my job. I want to define the condition dynamically by the code in tJava. It's possible?


Capture.PNG
manodwhb
Champion II
Champion II

@Mialy,use tJavarow and generate the values which you want and then use flowtoIterate component from  flowtoIterate  to connect to Oracleinput component,where in query of Basic settings tab , use that flowtoiterate current value in where condition.

Anonymous
Not applicable
Author

Can you give me a concrete example please?

Anonymous
Not applicable
Author

Hi,

 

    In the tjava component, you will have to provide basic if-else conditions to verify whether data is present for each column you are planning to compare. If the data is not present, populate the target context variable for each incoming column as empty string  else populate the context variable with inbound value.

 

    Once all parameters are checked, concatenate them and connect all the corresponding context variables in your tOracleinput component.

 

pseudo logic

 

context.where="where ";

if (var1_input is null) 

      {

        context.var1="";

       }

else 

      {

        context.var1= "table_name.col1="+var1_input;

      }

Similarly for next columns also... But please note that first column having not null should be prefixed with "where " and after that you need to use "and " to join the columns (you need to add logic here)

 

so final where clause will be:-

 

context.condition=context.where+context.var1+ context.and+context.var2...... etc.

 

Add this condition in the where clause of the tOracleinput.

 

"select * from employee "+ context.condition;

 

If the answer has helped you to resolve the issue, could you please mark the topic as solution provided?

 

Warm Regards,

 

Nikhil

 

 

Anonymous
Not applicable
Author

Thank you guys 0683p000009MACn.png