(In addition to Dan's comments ...)
If [the procedure] can't find anything it returns a query containing
an error message (i.e. no course found)
Then that means the COURSETYPE
column does not always exist in the resultset
, which is exactly what the error message is reporting. If the procedure returns any result, regardless of the contents, the code inside the cfif
block will execute. Since the first line of code uses that column, without verifying it exists, it would cause the exact error you are seeing.
Also, as I mentioned in the comments, you really need to localize the function variables result
, output
, temp
, etectera. Lack of var
scoping can create problems, even within same page, if you reuse variable names. As @Dan suggested you should fully scope all variables - in particular, the function arguments
.
(As an aside, I understand you are modifying existing code, but the error message should really be handled in CF, not inside the procedure. The procedure's job is just to return data. The CF code should check the recordCount and take the appropriate action if no records are found.)