DBResultSet>>#collect: 
Author Message
 DBResultSet>>#collect:

Dolphin 4.0 is terrific.  Really like the new Education Centre.  Great
job.

While trying out the tutorial on ODBC:

c := (DBConnection new)
        dsn: 'NWind';
        uid: 'Tony';
        pwd: 'alpha';
        connect.
rs := c query: 'select * from Orders'.
rs collect: [:x | x ShipName].

signals a <MessageNotUnderstood> exception for Array>>#addLast:.

DBResultSet >> collect: transformer
        "Evaluate the <monadicValuable> argument, transformer, for
each of the receiver's elements in the order defined by the receiver's
implementation of #do:.
        Answer a new collection like the receiver containing the
values returned by transformer on each evaluation.
        Implementation Note: Override back to Collection
implementation because superclass implementation needs exact #size,
which can be slow against DBResultSets."
        | answer |
        answer := self copyEmpty.
        self do: [:elem | answer addLast: (transformer value: elem)].
        ^answer

Either of the following works.  The OrderedCollection fix is slightly
faster but the WriteStream fix answers a result of the receiver's
species.

        | answer |
        answer := OrderedCollection new: self approxSize.
        self do: [:elem | answer addLast: (transformer value: elem)].
        ^answer

        | ansStrm |
        ansStrm := WriteStream with: (self species new).
        self do: [:elem | ansStrm nextPut: (transformer value: elem)].
        ^ansStrm contents

--
Richard A. Harmon          "The only good zombie is a dead zombie"



Tue, 26 Aug 2003 23:25:43 GMT  
 DBResultSet>>#collect:
Richard

Quote:

> Dolphin 4.0 is terrific.  Really like the new Education Centre.  Great
> job.

> While trying out the tutorial on ODBC:

> c := (DBConnection new)
>         dsn: 'NWind';
>         uid: 'Tony';
>         pwd: 'alpha';
>         connect.
> rs := c query: 'select * from Orders'.
> rs collect: [:x | x ShipName].

> signals a <MessageNotUnderstood> exception for Array>>#addLast:.

> DBResultSet >> collect: transformer

Thanks for the plaudits and the bug report.

This problem with DBResultSet>>collect: is a known bug (badly patched in
SP1). It is fixed in 4.01 (defect no. 19 it seems) along with over 100 other
bug fixes and enhancements. We hope to release it shortly as a free update
for 4.0 users, but are working on an Education Centre update to accompany
it.

Regards

Blair



Wed, 27 Aug 2003 04:43:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. D5: DBResultSet>>isEmpty

2. HELP>>>>>>>Fortran-Pascal Linking

3. >>>>>>>FROM SMTK TO C++

4. Bug in Interval>>collect:

5. ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

6. <<<<<YOU MUST CHECK THIS OUT >>>>>>>>>> 2103

7. >>>>>AVL tree

8. >>>>>How to read a IMAGE file?(BMP, GIF)|||||||||

9. ANNOUNCE>>>>>TOTAL FrameWork from Cincom

10. Slow/No Speed>>>>>>>>>

11. >>>>VHDL tutorial text: Summary >>>>

12. Graphics>>Rectangle>>intersects: erroneous code

 

 
Powered by phpBB® Forum Software