1. Andrea Rimicci
  2. PowerBuilder
  3. Thursday, 25 July 2019 12:52 PM UTC

The uploaded picture shows my issue:

using the same AND filter but with the two operands exchanged (a AND b the first, b AND a the second), I get different results.

I'd like to understand why results differ. Any help appreciated.

TIA, Andrea

Attachments (1)
Brad Mettee Accepted Answer Pending Moderation
  1. Thursday, 25 July 2019 13:31 PM UTC
  2. PowerBuilder
  3. # 1

You should be using parenthesis around the "not isnull..." to assure the evaluation of the statements occurs in the order you expect.

Try these:

(not isnull(sku)) and (not isnull(location))

(not isnull(sku)) and isnull(location)  // these two should evaluate the same now
isnull(location) and (not isnull(sku))

isnull(sku) and (not isnull(location))

 

By not using the parens, you're evaluating "not (isnull(sku) and isnull(location))" instead of "(not isnull(sku)) and isnull(location)". It's all dependent on how the statement is evaluated. Different languages put precedence in different orders. Using the parens forces it to be consistent.

Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Thursday, 25 July 2019 13:25 PM UTC
  2. PowerBuilder
  3. # 2

datawindow expressions have always used non-standard operator precedence 

so try using () to force the operator precedence that you want.

(not isnull(col1)) and isnull(col2)

vs

not (isnull(col1)) and isnull(col2))

 

 

Comment
There are no comments made yet.
Andrea Rimicci Accepted Answer Pending Moderation
  1. Thursday, 25 July 2019 14:31 PM UTC
  2. PowerBuilder
  3. # 3

Thanks for answers, I just wonder where the operator precedence is documented, because from the online guide I see PowerBuilder gives "NOT" higher precedence to "AND" (from "operator precedence, in PowerBuilder expressions" page), and parenthesis suggested if I want override.

Have the AND higher precedence to NOT is pretty strange, 'tho. Never seen this on any language. But want confirm if that was the issue, will do some checks with your suggestions. Thanks again.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.