AFter the query do this...
<cfif NOT get_featured_products.recordcount>
<cfset get_featured_products = QueryNew('id')>
</cfif>
That should fix the problem.
Rick Faircloth wrote:
> I'm running a query to get "featured products".
>
> For the call, I'm using:
>
> <cfinvoke component = "components.products"
> method = "select_featured_products"
> returnVariable = "featured_products"/>
>
> and the cffunction is:
>
> <cffunction name = "select_featured_products"
> displayname = "select_featured_products"
> hint = "Selects Featured Products"
> access = "remote"
> output = "false"
> returntype = "query">
>
> <cfset var featured_products = "" />
>
> <cfquery name="get_featured_products"
> datasource="#application.dsn#">
>
> select *
> from products
> where featured = 1
>
> </cfquery>
>
> <cfreturn featured_products />
>
> </cffunction>
>
> The problem I'm running into happens if there are no featured products
> and the query is empty. Then I get this error from CF:
>
> "The value returned from the select_featured_products function is not of
> type query."
>
> How should I modify this CFC (or the call) to work with or without query
> values?
>
> Thanks,
>
> Rick
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314241
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4