Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / April 2007



Tip: Looking for answers? Try searching our database.

SQL If statments

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
noobie2005 - 30 Apr 2007 20:29 GMT
Hi guys,

I was wondering if inside a CFQUERY statement you could find a way to see if a
Database field is empty and set still let it pass, would you use a SQL if
statement or the WHERE field IS NULL? How could this be done?
paross1 - 30 Apr 2007 20:57 GMT
WHERE field IS NULL

Phil
noobie2005 - 30 Apr 2007 21:15 GMT
Sorry, I'll try to better explain myself.

I have a query that totals all the devices in a given field, but, if that
table is empty, CF gives me an error that the variable I set, to see if the
amount on hand is less than what is needed, is undefined, and I wanted to know
if there was a way around that, so it could just read: "DBTABLE is empty, no
records exsist", or something along that line.....

I hope that's clearer, and wouldn't I just make a statement within the CFIF
statement stating that if DBFIELD EQ " " No Records Exsist?
paross1 - 30 Apr 2007 22:14 GMT
You could check the rceordcount variable for your query and if it is <> 0

<cfquery name="your_query" datasource="dsn">
SELECT your_fields
FROM your_table
WHERE whatever
</cfquery>

<cfif your_query.recordcount GT 0>
do whatever you want to do if you have records
<cfelse>
your alternative
</cfif>

Phil
Dan Bracuk - 30 Apr 2007 22:27 GMT
[q][i]Originally posted by: [b][b]noobie2005[/b][/b][/i]
Sorry, I'll try to better explain myself.

I have a query that totals all the devices in a given field, but, if that
table is empty, CF gives me an error that the variable I set, to see if the
amount on hand is less than what is needed, is undefined, and I wanted to know
if there was a way around that, so it could just read: "DBTABLE is empty, no
records exsist", or something along that line.....

I hope that's clearer, and wouldn't I just make a statement within the CFIF
statement stating that if DBFIELD EQ " " No Records Exsist?[/q]
What does "totals all the devices in a given field" mean?  What sql are you
running to determine that?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.