AnsweredAssumed Answered

How to set value of dynamic variable (associative array)?

Question asked by L.Elias Champion on Aug 14, 2014
Latest reply on Aug 15, 2014 by gcubed

I have an SQL query that returns several columns (and possibly several rows), some of which I want to loop through and under certain conditions, replace the value.

 

<sql:query var="q_idea" escapeText="false"><![CDATA[
  SELECT col1,col2,col3 FROM niku.INV_INVESTMENTS INVI
  JOIN niku.ODF_CA_INV ODFI ON INVI.ID = ODFI.ID
  WHERE ODFI.ID = ?
  ]]>
  <sql:param value="${gel_objectInstanceId}"/>
</sql:query>
<core:set var="var_columns" value="col1,col3" />


<core:forEach items="${q_idea.rows}" var="row" indexVar="vn_index">
  <core:forEach items="${var_columns}" var="var_column">
  <core:if test="${row.get(var_column) == 9}">
  <gel:log level="INFO" category="XOG">${var_column} value adjusted from 9 to 7</gel:log>
  <core:set var="row.get(var_column)">7</core:set>
  </core:if>
  <gel:log level="INFO" category="XOG">Value = ${row.get(var_column)}</gel:log>
  </core:forEach>
</core:forEach>


I can't get the inner set to work. The condition test is fine so I get in to that block since the log line gets output, but the value itself doesn't change. Anyone ever tried something like this?

Outcomes