Solved

Invalid SQL Data Reads In Crystal

Posted on 2014-09-10
7
350 Views
Last Modified: 2014-09-11
The report below queries the same SQL data that feeds our Sage CRM software. Record selection simply looks for any "Item" record that has a Cost higher than the sell-for Price, or a zero value for either the Cost or the Price. The actual formula is...

{AZItem.azit_Cost}>={AZItem.azit_Price} or isnull({AZItem.azit_Cost}) or isnull({AZItem.azit_Price}) or {AZItem.azit_Cost}=0
or {AZItem.azit_Price=0

The anomoly that I'm experiencing is, while Crystal indicates that Item #1104950012 has a zero Cost (red record in first image below), when I search for that Item in CRM, CRM indicates a Cost of $23.74 (and yes; I've confirmed that Crystal is looking at the correct field in the correct table).

Before querying the SQL data
In an attempt to figure out what was going on, I launched the SQL Server Management Studio and queried the table directly with...

select * from dbo.AZItem where azit_Number='1104950012'

The query returned one record which showed a cost of $23.74...agreeing with CRM and contradicting Crystal.

Now; here's the stumper...

When I re-ran the report, Item #1104950012 no longer appeared (image below). It is as if my looking at the record, via the SQL Server Management Studio, somehow "refreshed" (for lack of a better word) the data that Crystal was reading. And before you ask, "Save Data With Report" is, and always has been, unchecked.

After querying the SQL data
Can anyone here give me a clue as to what's going on here?
0
Comment
Question by:Bad_Fish
7 Comments
 
LVL 48

Expert Comment

by:PortletPaul
ID: 40315937
an update occurred between report runs?

Crystal is reading uncommitted records?
0
 

Author Comment

by:Bad_Fish
ID: 40315944
Thanks...but none of the above. I can replicate the above procedure with (from what I've seen) about 80% of the records. This was just one example to keep it simple.
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 200 total points
ID: 40316041
If the costs can really be NULL then you need to reorder the selection formula to put the IsNull tests first.

If Crystal tries to use a NULL vaue in any other formula than IsNull the execution terminates and the result is indeterminate.

isnull({AZItem.azit_Cost}) or isnull({AZItem.azit_Price}) or {AZItem.azit_Cost}>={AZItem.azit_Price} or {AZItem.azit_Cost}=0
or {AZItem.azit_Price=0


You may be getting the NULL on the record with the cost

mlmcc
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 34

Accepted Solution

by:
James0628 earned 300 total points
ID: 40316593
Just to add a little to what mlmcc said, if the records are not explicitly sorted, then the report may get them in a different order from one run to the next.  That could explain the changing results.

 James
0
 

Author Comment

by:Bad_Fish
ID: 40316929
mlmcc; For testing purposes, I modified the selection query to eliminate any chance that isnull is causing the problem. The record selection query now reads...

{AZItem.azit_Cost}=0 or {AZItem.azit_Price}=0 or {AZItem.azit_Cost}>={AZItem.azit_Price}

...and I'm still experiencing the problem. I believe the key bit of information here is the fact that my querying the record outside of Crystal forces Crystal to see the data correctly...as strange as that sounds.

Here are the steps in an example that summarizes what is happening...

1.

Crystal erroneously reports a zero value in a field that contains a positive number.

2.

A query of that record outside of Crystal confirms that the field contains a positive number.

3.

Crystal now reports the correct value stored in the field.
Any other ideas?
0
 

Author Closing Comment

by:Bad_Fish
ID: 40316994
After re-reading James0628's comment about sorting, I removed the group (based on a True or False formula) and the sort (ItemNumber) and Voilà...it's working correctly!

I'm going to dig a bit to find out why though; I don't understand how this could have had any affect on the values being read and reported.

Thanks to all!
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 40317096
WIth the groups and sorting the records depending on the report logic you may be evaluating the data in an incorrect order some of the time.

Without seeing the report and getting a good understanding of the data it would be difficult to determine what is really happening.

mlmcc
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to find all values in a column which is not money 25 27
Crystal Reports get subgroup count 1 22
SQl query 19 14
Service Statictic 11 13
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now