I try to create a Django QuerySet from an Oracle table-valued Function using the Models raw method:
XX.objects.raw("SELECT 1 as id, PROJEKT FROM TABLE(my_table_function())")
As soon as I evaluate the query set (access a model property)I get the error:
django.db.utils.DatabaseError: ORA-00942: table or view does not exist
After some debugging I figured out that Django adds a table name to the SQL statement when evaluating the QerySet including an Oracle table function:
XX.objects.raw("SELECT 1 as id, PROJEKT FROM TABLE(my_table_function())")
becomes
SELECT "CHARTS_XX"."ID", "CHARTS_XX"."PROJEKT" FROM "CHARTS_XX" WHERE CHARTS_XX"."ID" = %s
where "charts" is my app name and "XX" my Model.
Is there any way to force Django tu use the table function?
I have tested the table function using a SQL shell withour any problems.
Thanks!