[ RB4] To test a cursor ?
Tim Davis
timdavis at amug.org
Thu Oct 23 22:07:33 CDT 2003
Hi Thierry,
> Which is the best solution ?
>
> cur=Base. SQLSELECT ( ... )
>
> Which should the best test be made:
>
> FIRST
> if cur.recordCount < > then
> ...
> else
> msgBox " Empty "
> end
>
> SECOND
> If cur < > NIL then
> if cur.recordCount < > then
> ...
> else
> msgBox " Empty "
> end
> else
> msgBox "NIL"
> end
>
> LAST
> if cur < >NIL then
> ...
> else
> msgBox "NIL"
> end
>
> Before the first worked fine . Not now: Often / always (?) has ' the
> Nile Obbject Exception ' returned
>
> Is second model necessary or the third is it sufficient?
> In other words, if a cursor is not 'NIL', cursor.recordCount is not
> equal zero or can be equal zero ?
Its important to test for cursor to exist.
Another method (recently out on the RB tips list) which is clearer is:
if cur IsA Object then ...
Whether to check for records depends upon your use. (Of course you
meant to write "if cur.recordCount < > 0 then".)
Having a cursor and no records, you can still obtain information such
as field names.
If you check for RecordCount you can do something different like a "No
records found" dialog.
If you simply want to loop through the found records, then you don't
need to check for records, if there are none it will skip right through
the example below.
if cur IsA Object then
j = cur.RecordCount
for i = 1 to j
...
next
end
Hope that helps.
Tim Davis
More information about the Valentina
mailing list