[Zope-DB] DCOracle2 problems with Duplicate column names

Charlie Reiman creiman@kefta.com
Fri, 5 Jul 2002 10:49:48 -0700


I have not experienced this problem myself but there was a thread about it
not too long ago. The explaination is pretty straightforward. Column names
are mirrored as result object attributes, so you can fetch them with:

obj.FIELD1

It is the code that populates these attributes that can't grok the duplicate
names. You can work around it with an "AS" to rename the fields.

SELECT sysdate AS "BOB" from DUAL;

or, in case you already know what time it is:

SELECT a.field1 as "BOB", b.field1 as "DAVE"
FROM   table1 a, table2 b
WHERE  a.field2=b.field2;

I've had similar problems where SQL tries to return colum names line
"COUNT(STATS)" which you can't use very easily from python. It is not as
serious but it is annoying.

> -----Original Message-----
> From: zope-db-admin@zope.org [mailto:zope-db-admin@zope.org]On Behalf Of
> Mark Evans
> Sent: Friday, July 05, 2002 10:32 AM
> To: zope-db@zope.org
> Subject: [Zope-DB] DCOracle2 problems with Duplicate column names
>
>
> Hi,
>
> I have looked through the archives and I don't see a problem like this, so
> here
> goes.
>
> We are using Zope 2.5.1 on Solaris8 with Python2.1.1  We have
> several Oracle
> 8.1.7 databases running on W2K platforms that we are trying to access from
> Zope.
> If you have the following situation in Oracle:
>
> SQL> desc table1
>  Name            Type
>  ----------------------
>  FIELD1          VARCHAR2(10)
>  FIELD2          VARCHAR2(10)
>
> SQL> desc table2
>  Name            Type
>  --------------- ------------
>  FIELD1          VARCHAR2(10)
>  FIELD2          VARCHAR2(10)
>
> SQL> insert into table1 values ('Tom', '1');
> SQL> insert into table2 values ('Clancy','1');
> SQL> insert into table1 values ('David','2');
> SQL> insert into table2 values ('Eddings','2');
>
> Then you commit and execute this SQL from the SQL prompt
>
> SELECT a.field1, b.field1
> FROM   table1 a, table2 b
> WHERE  a.field2=b.field2;
>
> you get the result:
>
> FIELD1     FIELD1
> ---------- ----------
> Tom        Clancy
> David      Eddings
>
> However, when we execute this through a Z SQL Method, using a database
> connection that we have proven works in other cases, we get the following
> error:
>
> Error, exceptions.ValueError: Duplicate column name, FIELD1
> SQL used:
> select a.field1, b.field1
> from table1 a, table2 b
> where a.field2=b.field2
>
> Traceback (innermost last):
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/ZPublis
her/Publis
> h.py,
>
> line 150, in publish_module
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/ZPublis
her/Publis
> h.py,
>
> line 114, in publish
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/Zope/__
init__.py,
> line 158, in zpublisher_exception_hook
>     (Object: tabletest1)
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/ZPublis
her/Publis
> h.py,
>
> line 98, in publish
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/ZPublis
her/mapply
> .py,
> line 88, in mapply
>     (Object: manage_test)
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/ZPublis
her/Publis
> h.py,
>
> line 39, in call_object
>     (Object: manage_test)
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/Shared/
DC/ZRDB/DA
> .py,
> line 328, in manage_test
>     (Object: tabletest1)
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/Shared/
DC/ZRDB/DA
> .py,
> line 306, in manage_test
>     (Object: tabletest1)
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/Shared/
DC/ZRDB/DA
> .py,
> line 436, in __call__
>     (Object: tabletest1)
>   File
> /ulocal/local/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/Shared/
DC/ZRDB/Re
> sults.py,
>
> line 52, in __init__
> ValueError: (see above)
>
> Can someone explain what is happening here?  It seems that
> Zope/DCOracle is
> not
> properly recognizing table ownership. Our actual problem resulted from
> accessing
> tables across different owners schemas, but it boils down to this and is
> reproducible on multiple database machines.
>
> Thanks,
>
> Mark Evans
>
> mark.evans.b@bayer.com
>
>
>
>
>
> _______________________________________________
> Zope-DB mailing list
> Zope-DB@zope.org
> http://lists.zope.org/mailman/listinfo/zope-db
>