Page 1 of 1

SetVariable

Posted: Thu Oct 20, 2011 9:58 am
by a_houston
I am trying to get a record count from a file using a query and SetVariable task. I am using a simple record count as shown below:

<sql label="Connect to DB" resourceId="LOCAL" version="1.0">
<query label="Select Data" outputVariable="records">
<statement>Select count(*) From filelib.testfile </statement> </query>
</sql>


I then add a SetVariable task and my system places the following in the XML:

<setVariable name="foundcount" value="${records[1]}" version="2.0"

When I run the project I get the following error:

[8099 - setVariable] An unexpected error occurred. Cursor position not valid.

If I change the SetVariable statement to version 1.0 as shown below, it works correctly

<setVariable name="foundcount" value="${records[1]}" version="1.0" />

I have been unable to find anything that tells me what the correct syntax is for Version 2.0

Re: SetVariable

Posted: Thu Oct 20, 2011 11:43 am
by Support_Duane
There are two versions of the SetVariable task. You can use the SetVariable Version 1 task anywhere but it will only get data from the first row of the rowset or fileset. If you want to loop thru the rows of a rowset or filest, you need to use the SetVariable version 2 task. If you are just changing the value of a variable, then either version of the task can be used anywhere within GoAnywhere Director.

In your case, you need to change <setVariable name="foundcount" value="${records[1]}" version="2.0" to <setVariable name="foundcount" value="${records[1]}" version="1.0"