Reputation: 55
Modifying ODI knowledge Module (KM) to run an if condition using a Project variable. Rather then using the Global variable directly in the code, I want to store the variable in Option and call using GetOption method.
I have created a Option "Option1" and set the value to variable #GLOBAL.VAR1
Value of variable VAR1 is either 1 or 0.
<%for (int i=odiRef.getDataSetMin(); i <= odiRef.getDataSetMax(); i++){%>
<%=odiRef.getDataSet(i, "Operator")%>
select <%=odiRef.getPop("DISTINCT_ROWS")%>
<%=odiRef.getColList(i, ""," [EXPRESSION]\t[ALIAS_SEP] [CX_COL_NAME]", ",\n\t", "", "")%>
from <%=odiRef.getFrom(i)%>
where
<%if (odiRef.getOption("Option1").equals("1")) { %>
(1=2)
<%} else {%>
(1=1)
<% } %>
<%}%>
Code always generate the else statement. What am I doing wrong in this?
Upvotes: 0
Views: 2263
Reputation: 1385
I think that the problem is that your if statement does like this:
if("#PROJECT_VARIABLE.NAME".equals("1")) ...
So you are not evaluating the value, but the name of the variable that you put in the KM option.
Try to store the variable name into another substitution variable, in order to be substituted in the next level, like this:
<@ variable_name=<%=odiRef.getOption("Option1")%> @>
Upvotes: 0