Hello,
well i have a problem, i was wondering if there is a way to return a query in a function?
This is what i have so far, but i get an error.
<cffunction name="select_query" access="public" returntype="any">
<cfargument name="as" type="string" required="yes">
<cfargument name="status" type="string" required="yes">
<cfset var sql = "">
<cfset sql = "SELECT count(status) AS " & ARGUMENTS.as & " FROM table WHERE status = '" & ARGUMENTS.status 7 "'">
<cfquery name="get" datasource="Database">#sql#</cfquery>
<cfreturn get>
</cffunction>
<cfoutput>#select_query('New','New')#</cfoutput>
What im trying to do is return a number from the count statement, but im getting an error saying "You have an error in your SQL syntax; use right syntax near 'new''' at line 1. I didnt know why it has 3 apostrophes after new, so i tried deleting the apostrophes in the sql statement and i got the same error but now it had 'new' not 'new'''. How can i do this? Thanks for any help.