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     WHERE ISSUE WITH CALCULATION AND 'OR'

Read-Only Read-Only Topic
Go
Search
Notify
Tools
WHERE ISSUE WITH CALCULATION AND 'OR'
 Login/Join
 
Master
posted
Okay people, help me out here...

I know the obvious work-arounds.
I'm just can't figure out why this doesn't work as I think it should.


I like to select all car/models with x or x-1 seats... ...so I made this:
-SET &X = 5;

TABLE FILE CAR
	PRINT SEATS
	BY CAR
	BY MODEL
WHERE SEATS EQ &X OR &X-1
END

But it returns 0 rows...

Eeker

This works fine:
-SET &X = 5;

TABLE FILE CAR
	PRINT SEATS
	BY CAR
	BY MODEL
WHERE ( SEATS EQ &X ) OR ( SEATS EQ &X-1 )
END


And this works fine too:
-SET &X = 5;

TABLE FILE CAR
	PRINT SEATS
	BY CAR
	BY MODEL
WHERE SEATS EQ 5 OR 4
END


And this doesn't !
-SET &X = 5;

TABLE FILE CAR
	PRINT SEATS
	BY CAR
	BY MODEL
WHERE SEATS EQ 5 OR 5-1
END


Not even like this
-SET &X = 5;

TABLE FILE CAR
	PRINT SEATS
	BY CAR
	BY MODEL
WHERE SEATS EQ 5 OR (5-1)
END


WF can not perform calculation in a WHERE if there is also an OR involved? No matter how many brackets are added...?



For starters I found it strange ( compared to other languages ) that this accepted:
WHERE SEATS EQ 1 OR 4 OR 5
Especially with a NOT added
WHERE NOT SEATS EQ 1 OR 4 OR 5

I'd prefer an syntax error message over some unexplained results...


Anybody any clues?


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 668 | Location: Veghel, The Netherlands | Registered: February 16, 2010Report This Post
Expert
posted Hide Post
did you look at the sql?




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Virtuoso
posted Hide Post
Dave,
quote:
-SET &X = 5;

TABLE FILE CAR
PRINT SEATS
BY CAR
BY MODEL
WHERE SEATS EQ &X OR &X-1
END


There are 2 types of ORs:
expression OR expression
field EQ value OR value

In the quoted example, you are using the second type which demands a value not an expression.
Did you see if you got an error message?

I took your code and ran it (WF server 7.7.04M). I got, instead, the whole file!
Wonder why?
Since after the OR there isn't a value, WF looked at it as an expression, the value of which is not zero and treated is as TRUE, hence all the records. Neat, no?

So, why did you get 0 records?...


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

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Master
posted Hide Post
Both, thanks for the replies.
_______________________________________________________________________
@susannah

What SQL? It's a CAR sample...?!

On a real database this is shown:
 
08.52.27 BT  (FOC2565) THE OBJECT  OF IF/WHERE CANNOT BE CONVERTED TO SQL
08.52.27 BT  (FOC2566) WHERE WH$$$1 CANNOT BE CONVERTED TO SQL
08.52.27 BT  (FOC2583) NON-RELATIONAL OPERAND IS INVALID FOR OPERATION OR
08.52.27 BT  (FOC2590) AGGREGATION NOT DONE FOR THE FOLLOWING REASON:
08.52.27 BT  (FOC2598) FOCUS IF/WHERE TEST CANNOT BE PASSED TO SQL


Isn't that nice? i.e. it's 'handled' by WF-engine... not by SQL-engine?

_________________________________________________________________________
@Daniel


I know the difference between and operational OR and a logical OR.

But if
WHERE SEATS EQ 2 OR 4 OR 5
works fine...

It seem like it's used as a 'field EQ value OR value'
and it doesn't 'expect' an expression.

Then why does
WHERE SEATS EQ 5-3
does work?


Hence my question:
WF can not handle the -combination- of an expression and the use of 'OR' in a WHERE?


Consider it a logical OR doesn't work either.
WHERE SEATS EQ ( 4 OR 4 ) ( logically 4 OR 4 should always be 4 )


Greets,Dave


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 668 | Location: Veghel, The Netherlands | Registered: February 16, 2010Report This Post
Virtuoso
posted Hide Post
I thought Danny answered the question well.

In the documentation:
quote:
In a logical AND or OR test, all field names, test relations, and test values are explicitly referenced and connected by the words OR or AND.

quote:
In a literal OR test, the word OR is repeated between test values of a field name, but the field name itself and the connecting relational operator are not repeated.


As you are mixing logical(&X-1) and literal(&X) expressions, then the field names, test relations and test values MUST be explicitly referenced for the logical expression. So
WHERE SEATS EQ 2 OR 5 OR SEATS EQ 5-1
is the correct way to code.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Master
posted Hide Post
Thanks Alan for looking that up...


I got it now.

quote:

In a literal OR test...


I guess it means 2 things:
Part 1: You don't have to repeat the fieldname and connecting relational operator.
Part 2: You can not use expressions as 'test values'.

The last one wasn't that obvious to me...
I assumed the word 'literal' was only used to indicate 'as an test-operator' ( in contrast to 'as a logical-operator' )



I guess my knowledge of other programming languages is throwing me off.
No other language I know allows part 1 and disallows part 2.

I guess WG needs to allow part 1 in order to be able to handle the '1 OR 2 OR 3 OR 4' type of parameters filled by HTML pages.
( Why not use IN ( 1,2,3,4 ) ? Also nicer to display in the header of a report as selected values... )



Thanks all!

And no, I didn't see an error message, coz I didn't get any. ( e.g. like you get with a syntax error or label missing )
The only message you get is what I've posted earlier with TRACE on.



@IBI
quote:

08.52.27 BT (FOC2598) FOCUS IF/WHERE TEST CANNOT BE PASSED TO SQL


Isn't this odd?
There is no problem in passing 'WHERE SEATS EQ 5-1' but the is with 'WHERE SEATS EQ 5-1 OR 5'?

And I found that 'WHERE SEATS IN ( 2 , 5-1 )' translates to SQL : 'SEATS IN (2, 5, -1)'


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 668 | Location: Veghel, The Netherlands | Registered: February 16, 2010Report 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     WHERE ISSUE WITH CALCULATION AND 'OR'

Copyright © 1996-2020 Information Builders