Helpful Information
 
 
Category: ColdFusion Development
trim function

i had wrote a query to compare two data from two database. but when compare cos there is spaces after one data in the database. i tried to use the trim function but error occured stated unrecognised s.stud_ans. anyone can help?

<cfquery name="calculate" datasource="#pppk#">
SELECT count(*) AS calc_ans
from pEstudent_ans s INNER JOIN
#table_name# o ON #Trim(s.stud_ans)#=o.sub_ans
and s.stud_id= '#stud_id#'
and s.entry_id ='#entry_id#'
and o.ques_set ='#ques_set#'
and s.ques_no= o.ques_no
</cfquery>

Trim takes a string or a variable. When you do this:

#Trim(s.stud_ans)#

CF thinks that you are trying to trim a variable called "s.stud_ans" which I'm guessing does not exist. You can try #trim( 's.stud_ans' )#, but clearly there are no spaces there to trim.

Try trimming the variables that you ARE passing to the query, like #table_name#, #stud_id#, etc.










privacy (GDPR)