Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL expression sometimes returning null instead of data

Status
Not open for further replies.

JohnGa1

Programmer
Oct 26, 2007
6
GB
I'm using the following SQL expression to fill a field in a report:

(select "inc_cat_1"."inc_cat_sc"
from "inc_cat"
as "inc_cat_1"
where "incident"."incident_id" = "act_reg"."incident_id"
and "act_reg"."cause_id" = "inc_cat_1"."inc_cat_id"
and "inc_cat_1"."inc_type" = 'c')

inc_cat_1 is an alias to table inc_cat. The annoying thing is that sometimes it returns the correct value and sometimes doesn't, returning null instead. Looking in the application the correct value is always there, but I can't see any reason why null would be returned.
 
Sorry, forgot to mention, I'm running Crystal XI and SQL Server 2008.
 
If you don't want nulls, test for them and exclude them.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Is it returning only one value or multiple values? If multiple, the first value will be displayed on the report if you have that in a section other than detail section.
 
I'm doing some further investigating and will post. I assumed that more than one value would return an error, if this is not the case, then multiple values could be the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top