> > Have you any examples of poor or even terrible code that has really left you scrambling for a resolution to a weird error?
>
>
SELECT CPY.company_name, CTC.firstname, CTC.lastname ;
> FROM company CPY ;
> LEFT OUTER JOIN contacts CTC ON CTC.companyfk = CPY.companypk ;
> WHERE CPY.company_name LIKE "A%" ;
> INTO CURSOR cur_list
>
> SELECT cur_list
> SCAN
> lcName = ALLTRIM( lastname ) + IIF( NOT EMPTY( firstname ), ", " + ALLTRIM( firstname ), "" )
> *** More code here
> ENDSCAN
>
> The catch above? No test for NULLS! Note the OUTER JOIN in the query. Concatenating the names like this results in NULL if either the First, or Last name is NULL. It is an anomaly (if not actually a bug) that ALLTRIM( NULL ) returns NULL and not an error even though attempting to ALLTRIM() any other invalid data does throw an error.
>
> Regards
> Andy Kramek
> Microsoft MVP (Visual FoxPro)
>
Tightline Computers Inc, Akron Ohio, USAIf there's no contact for the company both name columns will be Null. You couldn't get a case where just the firstname is null, but lastname isn't, could you? I assume the default for the column s must be '', and NOT NULL.
-Anders