Page 1 of 1

Assigning rows affected to vaiiable

Posted: Wed Dec 06, 2017 2:21 pm
by deesloop
I must be missing something on the syntax of this.
I've a variable - I've ticked the Assign "rows affected" into Variable and entered {COUNTBEFORE}, which a step sets to zero initially.
Next step is to run the SQL SELECT ID FROM Ages which in SQL generate 600 rows or so.
I've ticked the Assign "rows affected into Variable" and entered {COUNTBEFORE} as the variable
Subsequent step is a message box to display the value of {COUNTBEFORE} however it is always zero.
If I change the initial setting of the value to 9999, {COUNTBEFORE} Is returned as 9999.

if I change the "Assign "rows affected" into Variable" and entered COUNTBEFORE without {}
I get an error of -1 which I presume is right.

It seems that either my SQL isn't correct (althought my syntax to update SQL is fine)
The value isn't being assigned to the variable.

Any help please?

Re: Assigning rows affected to vaiiable

Posted: Thu Dec 07, 2017 8:31 pm
by Oleg
I think that Rows Affected doesn't work with SQL SELECT
Usually this parameter used in queries like INSERT, DELETE, UPDATE

If you want to count rows use SQL group functions
The query
SELECT count(*) FROM Ages
returns only 1 row with 1 field. The value contains the number of rows.
Of course, you have to use Dataset loop to read this value