Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verification on IIF() in SQL clause
Message
From
15/03/2003 23:07:47
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Verification on IIF() in SQL clause
Miscellaneous
Thread ID:
00766260
Message ID:
00766260
Views:
59
With VFP 7, I was able to do something like this:
SELECT New.Numero,New.Titre AS Title,New.Message AS Summary,;
 IIF(New.Type=2,PADR(New.Url,250),;
  PADR(GetUrlArticleMagazine(New.Month,New.Year,New.Page,New.Type,New.Url),250) AS Url,;
 New.Creation FROM Temp;
 INNER JOIN New ON Temp.Numero=New.Numero;
 ORDER BY 5 DESCENDING INTO CURSOR Temp
where GetURLArticleMagazine() is:
FUNCTION GetURLArticleMagazine
PARAMETERS tnMonth,tnYear,tnPage
RETURN 'http://www.something...'
In VFP 8, I have found that even if the type is 2, that both conditions will be executed. Thus, it causes a problem as it's not suppose to execute both evaluations but only the one as per the type value.

So, I had to adjust it like this:
SELECT New.Numero,New.Titre AS Title,New.Message AS Summary,;
 GetUrlArticleMagazine2(New.Month,New.Year,New.Page,New.Type,New.Url) AS Url,;
 New.Creation FROM Temp;
 INNER JOIN New ON Temp.Numero=New.Numero;
 ORDER BY 5 DESCENDING INTO CURSOR Temp
where GetUrlArticleMagazine2() is:
FUNCTION GetURLArticleMagazine2
PARAMETERS tnMonth,tnYear,tnPage,tnType,tcUrl
LOCAL lcURL
lcURL=''
IF tnType=2
   lcURL=tcUrl
   ELSE
   lcURL='http://www.something...'
ENDIF
RETURN PADR(lcURL,250)
Is this the proper way to do it in VFP 8?
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
Next
Reply
Map
View

Click here to load this message in the networking platform