简体   繁体   English

Oracle错误ORA-01036:非法的变量名称/编号

[英]Oracle error ORA-01036: illegal variable name/number

Why am I getting this error in Oracle DB? 为什么在Oracle DB中出现此错误?

cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number cx_Oracle.DatabaseError:ORA-01036:非法的变量名称/编号

cur.execute("select jobid, jobname, technology, skillset, salary, minimumexp from job where technology=:technology or int(salary)>=:int(salary) or int(minimumexp)<=int(minimumexp)",{"technology":technology,"int(salary)":int(salary),"int(minimumexp)":int(minimumexp)})

I don't think that INT function is valid in this context; 我认为INT函数在这种情况下无效。 at least, it does nothing in Oracle. 至少,它在Oracle中什么也不做。 Unless I'm wrong, it converts float numbers into integers . 除非我错了,否则它将浮点数转换为整数 If that's so, try with the TRUNC function instead, as Python's INT cuts off decimals. 如果是这样,请改用TRUNC函数,因为Python的INT截断小数。

Besides, it seems that you used the colon sign (which represents a parameter , right?) on the wrong place (should be in front of the parameter name, not the INT (or TRUNC ) function). 此外,似乎您在错误的地方(应该在参数名称的前面,而不是INT (或TRUNC )函数)使用了冒号(代表参数 ,对吗?)。

For example: 例如:

No : or int(salary)   >= :int(salary)
Yes: or trunc(salary) >= trunc(:salary)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM