Not 100% sure where the problem is in your code, but there is a much neater way to achieve the same result.

If your database supports sub-selects, something like this should do the trick:

<!--- let's declare the groupID --->

<cfset custOpsGroupID = "287">

<cfquery name="getShoutStories" DATASOURCE="#Application.DSN#">
SELECT *
FROM #Application.tablePrefix#TABLESTORY
WHERE STATUS ='1' AND PAGEID IN (SELECT PAGEID
FROM #Application.tableprefix#TABLEPAGE
WHERE GROUPID = '#custOpsGroupID#')
AND STORYORDER = '0'
</cfquery>




If you're using a database that doesn't support sub-selects you could try this instead:

<cfquery name="qgetShoutPageIDs" datasource="#Application.DSN#">
        SELECT PAGEID
        FROM    #Application.tableprefix#TABLEPAGE
        WHERE   GROUPID = '#custOpsGroupID#'
</cfquery>

<cfquery name="getShoutStories" DATASOURCE="#Application.DSN#">
SELECT *
FROM #Application.tablePrefix#TABLESTORY
WHERE STATUS ='1' AND PAGEID IN (#quotedValueList(qgetShoutPageIDs.pageid)#)
AND STORYORDER = '0'
</cfquery>


I haven't tested any of the above code, so it might need a preserveSingleQuotes() in the second example, but the principle is right.

Spike


Hickman, Matt wrote:


Hi all,

Trying to achieve the below:

1)Set groupID = done!
2)Query table to get ALL pages belonging to this groupID = done!
3)Store these pageIDs in an array to use later = done!
4)Use the pageID values to then query another table to grab the "stories"
associated with the pageid in the array = ?????

I'm getting the following error: Complex object types cannot be converted to simple values.

Can I NOT loop over the array in the SQL???

Here's my code so far......................................

<!--- let's declare the groupID --->
<cfset custOpsGroupID = "287">

        <!--- now let's grab ALL pages from this group and store them in an
array to be used later--->
        <cfquery name="qgetShoutPageIDs" datasource="#Application.DSN#">
                SELECT PAGEID
                FROM    #Application.tableprefix#TABLEPAGE
                WHERE   GROUPID = '#custOpsGroupID#'
        </cfquery>        

        <!--- let's declare the array and values --->
        <cfset custOpsShout_pageID=ArrayNew(1)>   
        <cfoutput query="qgetShoutPageIDs">
                <cfset tmp=ArrayAppend(custOpsShout_pageID,
qgetShoutPageIDs.PAGEID)>
        </cfoutput>       
        <!--- end of the array --->

<!--- let's grab the story from each of the pageID's in the array above --->

<cfquery name="getShoutStories" DATASOURCE="#Application.DSN#">
SELECT *
FROM #Application.tablePrefix#TABLESTORY
WHERE STATUS ='1' AND PAGEID = '(<cfloop from="1" to="#arraylen(custOpsShout_pageID)#"
index="i">#custOpsShout_pageID#</cfloop>)'
AND STORYORDER = '0'
</cfquery>



********************************************************************** A new world of colour, sound and pictures awaits you: Vodafone Live! More details at http://www.vodafone.com.au/live/

**********************************************************************"
This correspondence is for the named person's use only. It may
contain confidential or legally privileged information or both. "
No confidentiality or privilege is waived or lost by any "
mistransmission. If you receive this correspondence in error, please
immediately delete it from your system and notify the sender. You must not disclose, copy or rely on any part of this correspondence if you are not the intended recipient.


Any views expressed in this message are those of the individual sender,
except where the sender expressly, and with authority, states them to
be the views of Vodafone.

This email has been checked for viruses.
**********************************************************************************************


--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/





-- Stephen Milligan Consultant for hire http://www.spike.org.uk



---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to