Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CASE-OPENED] Question - Should WHERE TOTAL be the last of your WHERE statements

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CASE-OPENED] Question - Should WHERE TOTAL be the last of your WHERE statements
 Login/Join
 
Platinum Member
posted
I haven't coded in a while and now we are upgrading from 7.2.5 to 7.6.5. But in the back of my memory, I thought that when you have IF and multiple WHERE statements, IF (simple) is before WHERE and WHERE TOTAL should last. Also do we not need parens when the 'test' changes
and shouldn't there be a semi-colon at the end of the statements?
Or am I thinking of old ways of coding?!

Example:
WHERE DEFCATTYPE EQ '11'
IF DEFCAT EQ
'110049'
OR '110050'
WHERE CAEXCLUDE NE 'Y'
WHERE POL_NO IS-NOT '$$$$1379$$$$'
WHERE POL_NO IS-NOT '$$$$9999$$$$'
WHERE TOTAL WPREM NE 0 OR EPREM NE 0 OR ILOSSPY NE 0 OR
ECOL1 NE 0 OR ECOL2 NE 0 OR ECOL3 NE 0 OR ECOL4 NE 0 OR
ECOL5 NE 0 OR ECOL6 NE 0 OR ECOL6 NE 0 OR
ECOL7 NE 0 OR ECOL8 NE 0 OR ECOL9 NE 0 OR
ECOL10 NE 0 OR ECOL11 NE 0 OR ILOSSAY NE 0
WHERE CAYEAR EQ &YR OR &YR1 OR &YR2 OR &YR3 OR
&YR4 OR &YR5 OR &YR6 OR &YR7 OR &YR8 OR
&YR9 OR &YR10
WHERE ACCT_DT EQ &ACCTDT OR &ACCTDT1
OR &ACCTDT2 OR &ACCTDT3 OR &ACCTDT4 OR &ACCTDT5
OR &ACCTDT6 OR &ACCTDT7 OR &ACCTDT8 OR &ACCTDT9
OR &ACCTDT10

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


WebFOCUS & ReportCaster 8.1.05, 7.7.03 - AIX/LINUX, FOCUS 7.6.13 MVS, Output PDF, XLS-XLSX, DOCX and HTML
 
Posts: 146 | Location: Atlanta, GA | Registered: May 31, 2007Report This Post
Expert
posted Hide Post
I don't remember anything being positional relative to IF and WHERE but I do have a couple of comments.

I rarely use IF anymore.

Multiple WHERE clauses are ANDed together. If you need to do an OR, put the conditions in the same WHERE clause and use parens for clarity.

WHERE clauses should end in a semi-colon though I forget sometimes.

If any of your variables can come into the program equated to FOC_NONE, then the WHERE should be all on one line or coded such that when the line is removed from focstack, you don't get a syntax error.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Virtuoso
posted Hide Post
I've never really used "IF" when filtering records out; having a broad background in SQL-based databases, the "WHERE" keyword stick to me easier, but to answer your main question, I've mixed WHERE and WHERE TOTAL in the same TABLE FILE request in no particular order and have never found any issues with it.

Did you get any errors or unexpected results when your tried it in your environment?

I would say that has more to do with your own development "style". I wouldn't mix IF's and WHERE's in the same statement especially when using WHERE exclusively allows me to accomplish what I need. I also think it makes your code "neater" and easier for someone else to maintain.

In the same line of thought, I'd usually put all of my WHERE's first as they relate to detail record selection and would leave the WHERE TOTAL at the end as they are naturally evaluated last by WebFOCUS after all data has been aggregated. Once again, it's just a matter of coding style.

Semicolons are optional and in some cases are even disallowed. For instance, the following structure:

WHERE RECORDLIMIT EQ 5;


always throws a syntax error in WF 5.3 due to the semicolon, so I decided not to use them at all in any of my WHERE's.

As far as parenthesis are concerned, their use is not required in the WHERE syntax; they have a semantic meaning when you need to alter the order of evaluation of certain expressions and, when dealing with very long expressions like the ones in your code I'd probably use them to enhance readability but this is yet another personal preference and not something mandatory.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Platinum Member
posted Hide Post
Thanks Ginny! I figured there should be a semi-colon here and there.


WebFOCUS & ReportCaster 8.1.05, 7.7.03 - AIX/LINUX, FOCUS 7.6.13 MVS, Output PDF, XLS-XLSX, DOCX and HTML
 
Posts: 146 | Location: Atlanta, GA | Registered: May 31, 2007Report This Post
Platinum Member
posted Hide Post
Thanks nsjen - You are so correct about style preference in writing code. My questions came to mind because the code was written by someone else. I guess I need to dust off my FOCUS manuals!


WebFOCUS & ReportCaster 8.1.05, 7.7.03 - AIX/LINUX, FOCUS 7.6.13 MVS, Output PDF, XLS-XLSX, DOCX and HTML
 
Posts: 146 | Location: Atlanta, GA | Registered: May 31, 2007Report This Post
Expert
posted Hide Post
FYI, WHERE TOTAL is process much later that WHERE as it must work after Sorting, Aggregation and COMPUTEs.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Platinum Member
posted Hide Post
Thanks Waz - Going back to basics. My style of coding was to use the syntax in the order of what gets processed.
Cheers!


WebFOCUS & ReportCaster 8.1.05, 7.7.03 - AIX/LINUX, FOCUS 7.6.13 MVS, Output PDF, XLS-XLSX, DOCX and HTML
 
Posts: 146 | Location: Atlanta, GA | Registered: May 31, 2007Report This Post
Expert
posted Hide Post
In the training material, there is a great diagram of the process, what and happens when.

If you've been on some of the cources, you may have a copy.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Platinum Member
posted Hide Post
Close - Unfortunately I do not have any of the materials from the course. I will have to reach out to my friends at IBI.


WebFOCUS & ReportCaster 8.1.05, 7.7.03 - AIX/LINUX, FOCUS 7.6.13 MVS, Output PDF, XLS-XLSX, DOCX and HTML
 
Posts: 146 | Location: Atlanta, GA | Registered: May 31, 2007Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CASE-OPENED] Question - Should WHERE TOTAL be the last of your WHERE statements

Copyright © 1996-2020 Information Builders