[cx-oracle-users] Do views have prefixes?
Brought to you by:
atuining
From: Brianna L. <bri...@gm...> - 2010-08-19 08:48:05
|
Hi again, This is probably more about Oracle than cx_Oracle, but my googling is not bringing me much today. There are a bunch of views that I am interested in, but to access them I seem to need to use an extra field to identify them. Does a field 'Owner' have special significance in Oracle? Why do I need to refer to the view as owner.view_name to be able to select data from it? What is this "owner" here? Is it a tablespace...? Some kind of prefix? The reason is that I'm trying to hook Django up to my existing database. In my models I can specify the database table name, (actually a view, but that seems to be OK), but I can't specify whatever the "owner" field is. Specfiying the table name as "$OWNER.EDIT_STATISTICS" (where $OWNER is the real value of owner, not the string 'owner') also does not work as the SQL escaping is not happy. It produces things like this: SELECT "$OWNER.EDIT_STATISTICS"."GROUP_NAME" FROM "$OWNER.EDIT_STATISTICS" which give a ORA-00942: table or view does not exist obviously what I need is SELECT "$OWNER"."EDIT_STATISTICS"."GROUP_NAME" FROM "$OWNER"."EDIT_STATISTICS" but what is this mysterious first field? thanks, Brianna >>> cursor.execute("select view_name from all_views where owner='%s'" % OWNER) <__builtin__.OracleCursor on <cx_Oracle.Connection to user @local>> >>> for c in cursor: ... print c ... [...] ('EDIT_STATISTICS',) [...] >>> myview = 'EDIT_STATISTICS' >>> cursor.execute("select * from %s" % myview) Traceback (most recent call last): File "<stdin>", line 1, in <module> cx_Oracle.DatabaseError: ORA-00942: table or view does not exist >>> cursor.execute("select * from %s.%s" % (OWNER, myview)) <__builtin__.OracleCursor on <cx_Oracle.Connection to user @local>> -- They've just been waiting in a mountain for the right moment: http://modernthings.org/ |