try writing it as ?upper(varname)rather than upper(?varname). If users are going to input the varname can't you somehow be sure to convert it to upper case before querying? I would take the upper out and see if it would work.
A problem is a problem only as long as it has a possible solution. Lacking that, it becomes a FACT!