Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verification on IIF() in SQL clause
Message
From
16/03/2003 11:47:29
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00766260
Message ID:
00766320
Views:
28
>It wasn't called for type=2 but was called in the stage where VFP determines the size of the field. Looks like VFP evaluates both expressions in IIF() to get correct size of a field. Here's another test wich demonstartes that.
SELECT *, ;
>		PADR(IIF(1=1, "1", myudf("2",RECNO())),1) ;
>	FROM test
>* z.z
>2 1
>
>As you can see myudf shouldn't be ever executed but it is for record #1. And again I see the same result in VFP7 and 8.

So, as the record for Type=2 was the first in Temp, that explains why it was acting like this. That might also explain why I never faced that situation before as I probably never encountered that specific scenario.

I guess the best approach is to select only the New.Type field as is in the cursor and then apply a SCAN on that cursor to get specific evaluation.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform