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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional problem

Status
Not open for further replies.

CryoGen

MIS
Apr 15, 2004
86
US
I'm sure I'm missing something simple, but if someone could show me where I'd appreciate it.

I'm running what I thought was a fairly simple CFIF-based conditional that doesn't seem to work as I hoped. The Form.date parameter is being passed, and my database has two records dated 2005-07-15. This conditional was designed to stop a record from being created if a date already exists, but it is not. Am I missing something on my logic?

Code:
<cfparam name="t_date" default="Form.t_date">
<cfparam name="report_id" default="report_id">

<CFQUERY NAME="qWeekEnding" DATASOURCE="yyy">
	SELECT      t_date, report_id
	FROM        report
	WHERE       t_date = '#Form.t_date#'
</CFQUERY>

<CFIF qWeekEnding.RecordCount NEQ 0>

Yes, there are records for 2005-07-15.<br>
Total Records: <CFOUTPUT>#qWeekEnding.RecordCount#</CFOUTPUT>

<CFELSE>

No, there are no records for 2005-07-15.<br>
Total Records: <CFOUTPUT>#qWeekEnding.RecordCount#</CFOUTPUT>

</CFIF>

... when I bang this against the database using a query for 2005-07-15, I get this result:

Code:
Yes, there are records for 2005-07-15.
Total Records: 2

This seems fine right? But when I change the logic from "<CFIF qWeekEnding.RecordCount NEQ 0>" to "<CFIF qWeekEnding.RecordCount EQ 0>" I get this result.

Code:
"No, there are no records for 2005-07-15.
Total Records: 2

The recordcount function is working properly in the display (there are two records), but not in the CFIF conditional. Am I doing something wrong here?
 
qWeekEnding.RecordCount EQ 0

if your query returns a NULL value then your qWeekEnding.RecordCount = 1

hope it helps
 
Is there a better way to test for the precence of specific record in the table? (i.e, a record with a specific date?)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top