On 22 Feb 2013 10:24, DeLong, Eric wrote:
<<SNIP>>
Even this would have issues if theSalutation was blank... The
correction for that is another %trim, unfortunately...
myString += %trim( %trim( theSalutation ) + ' ' +
%trim( theFirstName ) + ' ' +
%trim( theLastName ) );
We NEVER want to ASSUME that blanks in data fields will be
consistent...
FWiW: Perhaps the data could come from a SQL database TABLE or VIEW
and the assumption is made instead, that the database has ensured the
data is consistent, to reduce some coding in the application programs:
[code]
create table theTable
( theSalutation varchar(xx)
, theFirstName varchar(yy)
, theLastName varchar(zz) not null
, constraint SalutationOrFirstName check( theSalutation is not NULL
or theFirstName is not NULL )
, constraint SalutationUntrimmed check(
length(theSalutation)=length(trim(theSalutation)))
, constraint FirstNameUntrimmed check(
length(theFirstName)=length(trim(theFirstName)))
, constraint LastNameUntrimmed check(
length(theLastName)=length(trim(theLastName))) )
; -- Table THETABLE created
insert into theTable values
('Mr.', 'Eric', 'DeLong')
,(default, 'Eric','DeLong')
,('Mr.', default, 'DeLong')
; -- 3 rows inserted in THETABLE
insert into thetable(thelastname) values('DeLong')
; -- INSERT or UPDATE not allowed by CHECK constraint
SALUTATIONORFIRSTNAME.
insert into theTable values('Mr. ', 'Eric', 'DeLong')
; -- INSERT or UPDATE not allowed by CHECK constraint
SALUTATIONUNTRIMMED.
select /* likely has value encapsulated in a CREATE VIEW */
ifnull( theSalutation concat ' ', '' ) concat
ifnull( theFirstName concat ' ', '' ) concat theLastName
from theTable
; -- report follows
String Expression
Mr. Eric DeLong
Eric DeLong
Mr. DeLong
******** End of data ********
[/code]
As an Amazon Associate we earn from qualifying purchases.