on 11-21-2013 11:20 AM
In Crystal Report 2008 I use an "apparently correct" record selection formula with parenthesis like this:
({table1.field1} = 'value1' and {table1.field2} = 'value2') or ({table1.field1} = 'value3' and {table1.field2} = 'value4')
When I run the report it doesn´t show the expected result and if I select "show sql query" I can see the parenthesis has disappeared and due to priority from "and" over "or" the filter is not what I want.
I have tried a lot of parenthesis combinations, and the sql query always deletes it.
How can I solution this?
Thanks.
Hi.
I have been checking the query, and there is no problem with parenthesis deleting.
This:
({table1.field1} = 'value1' and {table1.field2} = 'value2') or ({table1.field1} = 'value3' and {table1.field2} = 'value4')
Is the same as this:
{table1.field1} = 'value1' and {table1.field2} = 'value2' or {table1.field1} = 'value3' and {table1.field2} = 'value4'
Due to priority of "and" over "or".
I don´t know why the first time I didn´t get the expected result and when I saw the trace without parenthesis I thought that was the problem. I tried to repeat the situation and the result is fine. There had to be another reason.
I have done one last test with this formula:
({table1.field1} = 'value1' or {table1.field2} = 'value2') and ({table1.field1} = 'value3' or {table1.field2} = 'value4')
where parenthesis are necessary to keep the sense, and in this case they remain.
My conclusion is that Crystal Report deletes the not necessaries parenthesis, but that is not a problem.
Thank you for your help and your time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi.
I send a report as you ask me, but I have to advise you that I have tried with different reports and all of them have the same problem.
I usually set the recordselectionformula via vb .net, but after the first problem (seeing the query at SQL Server Profiler) I confirmed the Crystal Report option had the same behavior.
As I said in my first post, I have tried with different logical operators and different parenthesis amount and location and in the final query all my parenthesis disappears.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't see a mention of any Service packs in this Discussion yet. I would highly recommend SP 6. I'll contact you via Direct message with a link.
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter
Is this the only record selection criteria you have?
Are there any more conditions separated by 'AND' and/or 'OR'?
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you share the report with saved data by selecting "Save data with Report" option selected in "File" menu?
Thanks,
Raghavendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.