September 28, 2007, 04:47 PM
JaywillConcatenation question
I have a PERSON synonym with three fields that I'd like to concatenate, remove extra spaces, and then chop off all but the first 30 characters.
The fields are:
LAST_NAME A57
FIRST_NAME A30
MIDDLE_NAME A30
I'd like it in this format:
LAST_NAME, FIRST_NAME MIDDLE_NAME
I tried coding TRIMMED_FULL_NAME as follows, but it only gave me "LAST_NAME,":
FULL_NAME/A120=TRIM('B',PERSON.PERSON.LAST_NAME, 57, ' ', 1, 'A57')||', '| TRIM('B', PERSON.PERSON.FIRST_NAME, 30, ' ', 1, 'A30') | ' ' | TRIM('B', PERSON.PERSON.MIDDLE_NAME, 30, ' ', 1, 'A30');
TRIMMED_FULL_NAME/A30=SUBSTR(120, FULL_NAME, 1, 30, 30, 'A30');
Any suggestions?
September 28, 2007, 05:06 PM
JimRiceTry this:
FULL_NAME/A120 = LAST_NAME || (', ' | FIRST_NAME) || (' ' | MIDDLE_NAME);
TRIMMED_FULL_NAME/A30 = SUBSTR(120, FULL_NAME, 1, 30, 30, 'A30');
Jim
September 28, 2007, 05:43 PM
JaywillThank you! That works perfectly.
October 01, 2007, 12:27 AM
PiipsterI'd make one change to Jim's:
FULL_NAME/A120 = LAST_NAME ||
((', ' | FIRST_NAME) || (' ' | MIDDLE_NAME)
));
TRIMMED_FULL_NAME/A30 = SUBSTR(120, FULL_NAME, 1, 30, 30, 'A30');
This way you can be sure this will work correctly with all output formats.
October 01, 2007, 11:25 AM
ihfPlipster, JimRICE:
Quick and easy solution. Nice job. P.S. JIMRICE not only did you play baseball well you code equally as well.
ira unix 5.3.6