Cfquery 'Result' Attribute Caveat
A great feature of
One thing I’ve come across is that the structure returned (by using the result attribute) is created where the query is executed and the value of ‘result’ references this struct in the local variable scope.
So an inline query followed by a reference to the ‘result’ struct would run fine:
1 2 3 4 5 6 7 8
But a problem exists when you have a query in a Component that is being returned by a method call. In this case the structure won’t exist in the calling templates ‘local’ scope and an exception will be thrown.
The simple way around this is to declare the ‘result’ attribute in the request scope:
1 2 3 4
Now you can reference the structure inside the calling template using the request scope:
1 2 3 4 5