Table aliasing not working in raw Oracle SQL queries inside Django

余生长醉 提交于 2020-01-05 04:36:11

问题


Considering the following Raw SQL query made in Django 1.5 to an Oracle backend that is actually working

cursor.execute("SELECT EGW.TF_BSC_CELTCHH.BSC FROM EGW.TF_BSC_CELTCHH WHERE ROWNUM <= 5")

But if I try to use an alias for the table name like this:

cursor.execute("SELECT TCHH.BSC FROM EGW.TF_BSC_CELTCHH AS TCHH WHERE ROWNUM <= 5")

I get the following error:

ORA-00933: SQL command not properly ended

Why table aliasing is causing such trouble in Oracle?


回答1:


Don't use AS, just type ...

cursor.execute("SELECT TCHH.BSC FROM EGW.TF_BSC_CELTCHH TCHH WHERE ROWNUM <= 5")

That way it should work.

Cheers!



来源:https://stackoverflow.com/questions/16406140/table-aliasing-not-working-in-raw-oracle-sql-queries-inside-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!