How do I set and increment / decrement a variable
How do I set and increment / decrement a variable
It looks like all variables are text and not numeric. When I try to add +1 to a variable, I get the equation as the variable:
${counter} = ${counter} + 1
Frank
- Frank_CMRG
- Posts: 8
- Joined: Wed Dec 08, 2010 12:49 pm
Re: How do I set and increment / decrement a variable
However, you can use SQL to increment or decrement (or apply any other math function) to a variable value.
for example:
- Code: Select all
<sql label="SQL" version="1.0" resourceId="Resource Name">
<query label="create table">
<statement>create table qtemp.filecount (files NUM(3))</statement>
</query>
<query label="insert count value" whenNoDataFound="continue">
<statement>INSERT INTO qtemp.filecount(files) values(${filesFound} + 1)</statement>
</query>
<query label="Get File_Count" outputVariable="File_Count">
<statement>SELECT files from qtemp.filecount</statement>
</query>
</sql>
<setVariable version="1.0" name="FileCount" value="${File_Count[1]}" />
If desired the above code could be placed in a loop and either add a drop table query or use a permanent library/schema and create the table before entering the loop and drop it when the process is complete.
The ${filesFound} variable would have to be initialized before the above code is executed.
- Support_Duane
- Support Specialist
- Posts: 66
- Joined: Thu Mar 05, 2009 2:49 pm
Who is online
Users browsing this forum: No registered users and 1 guest