Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: SQL
Miscellaneous
Thread ID:
00414860
Message ID:
00414867
Views:
17
>HELLO,
> What did I do wrong in the following statement it returns no record:
> select orders.id, iif(isnull
> (clients.name), "Sir/Madam",clients.name) as name ;
> from orders,clients ;
> where orders.id == clients.order_id ;
> into cursor temp
>what I am trying to do is if the order has a contact name I will print out the name otherwise just say "sir/madam". thanks.
>sherry


Sherry, first name is VFP reserved word which can cause the problem,
second, IIF should be like:

IIF(ISNULL(clients.client_name), PADR("Sir/Madam", LEN(clients.client_name), PADR(clients.client_name, LEN(clients.client_name))) AS the_name

otherwise the lenght of resulting the_name field will be limited with the value obtained from the first matching record.

you may try also with EMPTY(clients.client_name) (or using EMPTY() OR ISNULL())
and also

SELECT ... ;
FROM orders ;
INNER JOIN clients ;
ON orders.id == clients.order_id ;
INTO CURSOR temp
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform