mercredi 24 février 2016

Django: Query return [ ] when using variables compare to using exact value

Good day,

Having problem in comprehending the reason behind this problem. The query generated the expected results when using exact value for variable 'StepNo'. However when using 'StepNo' as variable in the query it return [ ]. Others variables such as 'skill_id' and 'exeQueNum' worked just fine. Even used those variables in place of 'StepNo' and it produce the expected result. Just cannot comprehend why 'StepNo' would not produce the expected result.

StepNo = 1
skill_id = 1
exeQueNum = 2

cur.execute("""SELECT polls_exe_working.[exeStepAnswer],  polls_exe_working.[exeStepHint], polls_exe_working.[exeHintVisualAid], polls_exe_working.[exeGeneralFeedback], polls_exe_working.[exeCongratulatory]
FROM polls_exercise
INNER JOIN  polls_exe_working
ON polls_exercise.[exercise]=polls_exe_working.[exercise_id]
WHERE polls_exercise.[skill_id]="skill_id" AND (polls_exe_working.[exeWorkStepNo]="StepNo" AND polls_exercise.[exeQueNum]="exeQueNum")""")

StepAnswer = dictfetchall(cur)
print "StepAnswer", StepAnswer

Aucun commentaire:

Enregistrer un commentaire