Quite some time ago I ran into this problem. Thanks to the miracle of ZIP files I had this snippet lying around:
* create the test data
CLEAR all
CREATE CURSOR 'Table_A' ( ID_A I(9), Name C(32))
CREATE CURSOR 'Table_B' (ID_B I(9), ID_A I(9), Phone C(14))
INSERT INTO 'Table_A' ( ID_A, Name ) VALUES ( 1, 'Jenny' )
INSERT INTO 'Table_A' ( ID_A, Name ) VALUES ( 666, 'Damien' )
INSERT INTO 'Table_A' ( ID_A, Name ) VALUES ( 2, 'Bubba' )
INSERT INTO 'Table_B' ( ID_A, ID_B, Phone ) VALUES ( 1, 445445, '(915) 867-5309' )
INSERT INTO 'Table_B' ( ID_A, ID_B, Phone ) VALUES ( 666, 333333, '(212) 666-6666' )
INSERT INTO 'Table_B' ( ID_A, ID_B, Phone ) VALUES ( 2, 445445, '(404) 127-5490' )
INSERT INTO 'Table_B' ( ID_A, ID_B, Phone ) VALUES ( 1, 777777, '(915) 867-6244' )
INSERT INTO 'Table_B' ( ID_A, ID_B, Phone ) VALUES ( 1, 445445, '(915) 867-5300' )
SELECT Table_A.Name, Table_A.ID_A, Table_B.ID_B, Table_B.Phone ;
from 'Table_A' JOIN 'Table_B' ON Table_B.ID_A = Table_A.ID_A ;
ORDER BY name ;
into cursor 'fred'
* perform an aggregate "collection"
Select 'fred'
STORE 0 TO oldid
STORE "" TO daname,zan
SCAN
IF id_a # oldid
DO doprint WITH daname
zan = phone + " "
oldid = id_a
daname = name
ELSE
zan = zan + phone + " "
ENDIF
ENDSCAN
DO doprint WITH daname
PROCEDURE doprint
LPARAMETERS thename
IF LEN(thename)>0
? ALLTRIM(thename)
?? oldid at 10
?? zan at 25
ENDIF
ENDPROC
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only