Solved

Invalid SQL Data Reads In Crystal

Posted on 2014-09-10
7
354 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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