[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
RE: [sqr-users] if statement syntax
- Subject: RE: [sqr-users] if statement syntax
- From: "Laura Mayer" <lmayer@gw.housing.umass.edu>
- Date: Wed, 25 Oct 2006 13:39:47 -0400
- Delivery-date: Wed, 25 Oct 2006 13:42:13 -0400
- List-id: "This list is for discussion about the SQR database reportinglanguage from Hyperion Solutions." <sqr-users.sqrug.org>
Yikes! I liked your first answer better :)
And here I thought I was asking a simple one sentence answer.
Thanks for taking the time to clarify.
>>> ceprn@hotmail.com 10/24/2006 6:49 PM >>>
OK, I'd like to change my answer......
I'd like to suggest that you always group your logical expressions with
parenthesis in the order you want the logical statement evaluated. I use
parenthesis when I use an if statement, even if I only have 1 or or 1 and;
it just makes it easier to read and separates it into a logical (no pun
intended) grouping.
OK, expanding... As I guess I was getting sqr confused with some other
language, according to the sqr language reference manual I have, logical
functions are processed in this hierarchy in SQR:
||
+,- (sign prefix)
^
*,/,%
+,-
>, <, >=, <=, <>, !=, =
not
and
or, xor
NOTE : anything on a given line above or below, if it's the same type gets
processed left to right, ie 5 + 6 - 7. goes (5+6) - 7 aka 11 - 7
for Oracle, the sequence is
+, - (sign prefix)
*, /
+, -, ||
=, !=, <, >, <=, >=, IS NULL, LIKE, BETWEEN, IN
NOT
AND
OR
So, as my dba friend pointed out to me as we were doing testing while
chatting on the phone, in your statement "if $HasInactiveRow = 'Y' or
$IsResident='N' AND $comment<>'New To Bldg'"
this would be processed (as it sits) as...
1) $HasInactiveRow = 'Y' evaluates to true or false
2) $IsResident='N' evaluates to true or false
3) $comment<>'New To Bldg' evaluates to true or false
4) true from 2 AND true from 3 have to evaluate to true
5) true from 1 or true from 4 will give you a true condition for this if
statement and allow further processing.
As you can also see, if statements in sqr will process in a slightly
different precedence than where clauses in oracle, so keep that in mind.
hope this confuses. :-p
peace,
clark 'the dragon' willis
PSA: Salary <> Slavery. If you earn a salary, your employer is renting your
services for 40 hours a week, not purchasing your soul. Your time is the
only real finite asset that you have, and once used it can never be
recovered, so don't waste it by giving it away.
I work to live; I don't live to work.
"Time is the coin of your life. It is the only coin you have, and only you
can determine how it will be spent. Be careful lest you let other people
spend it for you."
Carl Sandburg
(1878 - 1967)
It is impossible to defeat an ignorant man in argument.
William G. McAdoo
----Original Message Follows----
That depends on how you want it processed... with no parens, it processes
from L to R.
If you logic has to be either the first condition or the second condition
and the third condition, then it is fine...
If you want it any other way, such as either condition1 or (cond 2 and cond
3) then you need parens
peace,
clark 'the dragon' willis
----Original Message Follows----
Good afternoon,
I'm trying to say
if $HasInactiveRow = 'Y' or $IsResident='N' AND $comment<>'New To Bldg'
Does this have to be in parentheses or something for it to evaluate all
together?
Thanks in advance.
Laura
_________________________________________________________________
Add a Yahoo! contact to Windows Live Messenger for a chance to win a free
trip!
http://www.imagine-windowslive.com/minisites/yahoo/default.aspx?locale=en-us&hmtagline
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users