Focal Point
[SOLVED] What is the difference between 'IF' and 'WHERE'?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/166102021

May 19, 2009, 09:41 AM
webmeister
[SOLVED] What is the difference between 'IF' and 'WHERE'?
Can anyone please tell me what the difference is between using 'IF' and using 'WHERE' ? I've seen a couple of explanations in this forum, but they left me a little confused.

By thwe way, I am still using Mainframe FOCUS 7.1.1 - it's great working for a college that uses old technology Roll Eyes

This message has been edited. Last edited by: Kerry,


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO
May 19, 2009, 10:00 AM
GamP
The main difference is that IF can not compare fields, WHERE can.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
May 19, 2009, 10:02 AM
<JG>
Basically

IF test a value

Where do the same but with the ability to use expressions as you can in relational DBs
May 19, 2009, 10:13 AM
Francis Mariani
Among several differences between IF and WHERE are:

The operators you can use, see "Creating Reports With WebFOCUS Language > Selecting Records for Your Report > Using Operators in Record Selection Tests" in the documentation.

Syntax for reading selection values from a file is different, see "Creating Reports With WebFOCUS Language > Selecting Records for Your Report > Reading Selection Values From a File", which also describes the limits of both IF and WHERE.

According to "Creating Reports With WebFOCUS Language > Selecting Records for Your Report > Selecting Records Using IF Phrases":

quote:
Tip: Unless you specifically require IF syntax (for example, to support legacy applications), we recommend using WHERE.



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
May 19, 2009, 10:58 AM
Danny-SRL
quote:
Tip: Unless you specifically require IF syntax (for example, to support legacy applications), we recommend using WHERE.


I beg to differ.
In my view it is the opposite: Unless you specifically require WHERE syntax (for complex conditions using OR), I recommend using IF.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

May 19, 2009, 11:34 AM
Francis Mariani
Daniel,

You're begging to differ with the Information Builders tip.

Why do you prefer IF over WHERE?

By the way, I have not used an IF selection statement for the last five or seven years and have been quite happy.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
May 19, 2009, 11:45 AM
Prarie
I have found on occasion - and unfortunetly can't think of an example of what I was doing - that a WHEREe did not work...and I had to use IF.


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
I, as Francis, have not used IF for several years in favor of the WHERE. But then again, I have not done a Legacy application since 2001.

I’m curious as to where "a WHERE did not work".
The only time I can think of where an IF is preferable to a WHERE is for selection criteria in a file - something to do with the number of records in the file or the total file size.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
quote:
great working for a college that uses old technology


Don't you mean Mature Smiler


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

Webmeister,

Old technology. Let me add to this with regard to this post.
In the 'old' days, when the WHERE statement was newly introduced to focus, it was actually transformed into a define based selection. In these times it would be best to use an IF where possible, since that would do the selection directly against the database record, instead of first doing the 'under-the-covers-define' and then the selection, resulting in IF being slightly faster than WHERE (and theoretically it could produce a slghtly different result set).
Nowadays, the process of dealing with WHERE is much more sophisticated and is translated into IF where possible.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
To all who replied, THANK YOU!! Your responses are most appreciated.


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO