Question
Need Help with CFC That Requires URL Vars
After finally upgrading to CFMX-7, am writing my first CFC.
CFC consists of/contains a query, whose arguments can be passed as
URL variables (the CFC is called from a drill-down program). Only
problem is, the CFC's query contains the following WHERE statement:
WHERE (sales_code = '#ARGUMENTS.sales_code#') AND
(location IN
<CFOUTPUT QUERY = "GetLocations" maxrows="1">
(#QuotedValueList(GetLocations.location)#)
</CFOUTPUT> ) AND
(more where statements using #ARGUMENTS.whatever#)
Problem is HOW TO HANDLE the <b> #QuotedValueList(GetLocations.location)#</b>
This "location list" is populated by a query that runs BEFORE this query, depending on what REGION the user selected on the report's main form (there are 20 regions avail in the form's drop-down list). If the user selected, for example, the EAST REGION, the first query would populate the <b> #QuotedValueList(GetLocations.location)#</b> with all the locations in that region.
So I'm not sure how to set up the first query so it can pass, as an argument, the values in the location list. I don't think CFC's can contain URL variables, nor can they contain queries that don't start with <CFCOMPONENT> and <CFFUNCTION>.
Thought about setting up the first query as a UDF, contained inside the .CFM file that's calling the CFC. But then not sure if I can pass the UDF's return value as a "list of locations" (i.e., <b> #QuotedValueList(GetLocations.location)#</b> ) as an ARGUMENT for the CFC's query/WHERE statement.
Hope this makes sense. The UDF and CFC examples provided in my CF Developer's journals and other CF books are very basic examples on using UDFs and CFCs, nothing quite this complex. Or maybe my brain is making it a bigger deal out of this, than it really is.
Any help/advice on how to "structure" something like this would be much appreciated (e.g., PUT GetLocations query in main .CFM file, how to get the location list into the CFC's query, etc. And can you use something like
<b> #QuotedValueList(ARGUMENTS.location)#</b>, in place of <b> #QuotedValueList(GetLocations.location)#</b>, and if so, how do you pass the argument's value to the CFC?
Thanks for any help/advice.
Gary.
WHERE (sales_code = '#ARGUMENTS.sales_code#') AND
(location IN
<CFOUTPUT QUERY = "GetLocations" maxrows="1">
(#QuotedValueList(GetLocations.location)#)
</CFOUTPUT> ) AND
(more where statements using #ARGUMENTS.whatever#)
Problem is HOW TO HANDLE the <b> #QuotedValueList(GetLocations.location)#</b>
This "location list" is populated by a query that runs BEFORE this query, depending on what REGION the user selected on the report's main form (there are 20 regions avail in the form's drop-down list). If the user selected, for example, the EAST REGION, the first query would populate the <b> #QuotedValueList(GetLocations.location)#</b> with all the locations in that region.
So I'm not sure how to set up the first query so it can pass, as an argument, the values in the location list. I don't think CFC's can contain URL variables, nor can they contain queries that don't start with <CFCOMPONENT> and <CFFUNCTION>.
Thought about setting up the first query as a UDF, contained inside the .CFM file that's calling the CFC. But then not sure if I can pass the UDF's return value as a "list of locations" (i.e., <b> #QuotedValueList(GetLocations.location)#</b> ) as an ARGUMENT for the CFC's query/WHERE statement.
Hope this makes sense. The UDF and CFC examples provided in my CF Developer's journals and other CF books are very basic examples on using UDFs and CFCs, nothing quite this complex. Or maybe my brain is making it a bigger deal out of this, than it really is.
Any help/advice on how to "structure" something like this would be much appreciated (e.g., PUT GetLocations query in main .CFM file, how to get the location list into the CFC's query, etc. And can you use something like
<b> #QuotedValueList(ARGUMENTS.location)#</b>, in place of <b> #QuotedValueList(GetLocations.location)#</b>, and if so, how do you pass the argument's value to the CFC?
Thanks for any help/advice.
Gary.
