Focal Point
Row Concatenation

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3441058331

April 27, 2005, 11:27 AM
IAMARTEB
Row Concatenation
I am trying to concatenate multiple rows of email addresses into one row of data. The row will be variable length since there could be as many as 50 emails to combine. The email field in the database is 50 characters (A50) and will need a semi-colon delimiter added to the end of each email address. The row would also begin with a fixed field in front of the email addresses (ie. �All Group Distribution �).

The hold file would look something like this:

al@cba.com
jan@xyz.com
jim@def.com
jack@fen.org
kim@abc.com
john@info.com

The output would be all on one row (as follows):

All Group Distribution al@cba.com;jan@xyz.com;jim@def.com;jack@fen.org;kim@abc.com; john@info.com

The semi-colon on the last email at the end of the row should also be eliminated.

Any help would be greatly appreciated !
April 27, 2005, 02:14 PM
<Pietro De Santis>
This should get you started:

DEFINE FILE CAR
EMAIL_ADDRESS/A50 = COUNTRY || '@CARCOMPANY.COM';
EMAIL_ADDRESS2/A3060 = IF EMAIL_ADDRESS2 EQ ''
THEN 'All Group Distribution ' | EMAIL_ADDRESS
ELSE SUBSTR(3000, EMAIL_ADDRESS2, 1, 3000, 3000, 'A3000') || ';' || EMAIL_ADDRESS;
END

TABLE FILE CAR
SUM EMAIL_ADDRESS2
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, FONT='VERDANA', SIZE=6, $
ENDSTYLE
END

EMAIL_ADDRESS is a field to simulate your email address field.

EMAIL_ADDRESS2 is the concatenation of all the email addresses. The SUBSTR function is used bacause you need to concatenate the previous row's email addresses to the current row's email address.

SUM is used to summarize the input into one output row.

Cheers.
April 27, 2005, 02:28 PM
Prarie
Very Good...