BUG: ADODBRecordset15<<do: Errors on an empty recordset...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

BUG: ADODBRecordset15<<do: Errors on an empty recordset...

Christopher J. Demers
The method ADODBRecordset15<<do: raises an error on an empty recordset.  I
think this is inconsistent with the normal expectations of Smalltalk do:.  I
believe it should simply do nothing if the recordset is empty.  I think the
problem is the MoveFirst, as this will error if the recordset is empty.  I
have fixed this (code attached bellow) by doing an eof check before the move
first.  One could raise the question: "What if one wanted to iterate over a
recordset twice?".  The method recordCount seems to like to return -1, which
is not very helpful.  Perhaps the message MoveFirst could be wrapped in an
error trap?  Or perhaps there is a better test that some ADO guru knows.  I
will leave these decisions to the wizards of OA, but whatever the case I
believe do: should not error on an empty recordset.  My partial fix is
included bellow:

==============
ADODBRecordset15<<do: operation
"Evaluate the <monadicValuable> argument, operation, for each of the
records in the receiver."
| fields |
"cdemers - 11/13/2003 Added to make this act like a normal do, doing nothing
if the collection is empty,
before the eof check it would raise an error."
self eof ifTrue: [^self].
self MoveFirst.
fields := self fields.
[self eof] whileFalse: [
operation value: fields.
self MoveNext]
==============

Chris


Reply | Threaded
Open this post in threaded view
|

Re: ADODBRecordset15<<do: Errors on an empty recordset...

Blair McGlashan-2
"Christopher J. Demers" <[hidden email]> wrote in
message news:bp1faf$1jvbo4$[hidden email]...
> The method ADODBRecordset15<<do: raises an error on an empty recordset.  I
> think this is inconsistent with the normal expectations of Smalltalk do:.
I
> believe it should simply do nothing if the recordset is empty.  I think
the
> problem is the MoveFirst, as this will error if the recordset is empty.  I
> have fixed this (code attached bellow) by doing an eof check before the
move
> first.  One could raise the question: "What if one wanted to iterate over
a
> recordset twice?".  The method recordCount seems to like to return -1,
which
> is not very helpful.  Perhaps the message MoveFirst could be wrapped in an
> error trap?  Or perhaps there is a better test that some ADO guru knows.
I
> will leave these decisions to the wizards of OA, but whatever the case I
> believe do: should not error on an empty recordset.  My partial fix is
> included bellow:
>

Thanks Chris, we'll take a look at this issue for PL3.

Regards

Blair