SunQuest
           ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 2nd, 2005, 01:03 PM
babygodzilla babygodzilla is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 197 babygodzilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 28 m 35 sec
Reputation Power: 5
check if recordset exists?

how do i check if a recordset exists? i can't use isDefined() that wont work for queries. can't user .recordcount or len() because they assume and the recordset exists in the first place. any ideas?

Reply With Quote
  #2  
Old March 2nd, 2005, 02:00 PM
VelvettFogg VelvettFogg is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 34 VelvettFogg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 13 m 46 sec
Reputation Power: 4
<cfif queryName.recordCount gt 0>

record set exists

</cfif>

Reply With Quote
  #3  
Old March 2nd, 2005, 02:10 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,626 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 6 m 34 sec
Reputation Power: 53
isDefined() will certainly work on a query name. You can also do:

<cfif structKeyExists( variables, 'myQueryName' )>

(assuming the query is in the variables scope of course).
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #4  
Old March 3rd, 2005, 09:31 AM
babygodzilla babygodzilla is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 197 babygodzilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 28 m 35 sec
Reputation Power: 5
but isDefined() did NOT work, i got an error saying isDefined() will not work on complex variables, such as a recordset. and again, .recordcount did NOT work because that assumes the recordset exists in the first place. if the recordset does not exist it'll blow up saying ".recordcount is not defined in variable [insert name here]" or something along those lines

Reply With Quote
  #5  
Old March 3rd, 2005, 09:49 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,626 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 6 m 34 sec
Reputation Power: 53
You might try being a bit less emphatic, because I am telling you that you are doing something wrong. I think what you mean is "I can't make it work" or "It's not working for me". This code works fine and both conditions are met.

Code:
<cfquery name="qryGetCatalog" datasource="wegotwidgets">
  select productID,
         productName,
         productDescription,
         imageFile,
         price
    from Products
order by productName
 </cfquery>

<cfif isDefined( 'qryGetCatalog' )>
its defined
</cfif>
<br><br>
<cfif structKeyExists( variables, 'qryGetCatalog' )>
the struct key exists
</cfif>


I recommend using structKeyExists() instead of isDefined() because it is more specific (it's forcing a lookup in only the variables scope, while isDefined() will automatically look for the variable in any of the auto-lookup scopes beyond the variables scope).

Last edited by kiteless : March 3rd, 2005 at 09:54 AM.

Reply With Quote
  #6  
Old March 3rd, 2005, 12:07 PM
babygodzilla babygodzilla is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 197 babygodzilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 28 m 35 sec
Reputation Power: 5
oh ok i see... thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > check if recordset exists?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway