Mailing List Archive

Combine Result Sets
Hello,

I have been searching both online and in this list's archives. I am still a bit stumped however. I have two different ODBC connections to two different Caché DB's. They have the exact same structure and column names and types. I run a query against each of the connections and get back a Shared.DC.ZRDB.Results class in each case.

Has anyone come up with code to combine the results? I would be much appreciative. If not, a pointer in the right direction would be helpful.

Thank you,

Dale Hirt
Re: Combine Result Sets [ In reply to ]
On 2005-09-23 at 18:14:40 [+0200], Dale Hirt <dale@sbcltd.com> wrote:
> Hello,
>
> I have been searching both online and in this list's archives. I am still
> a bit stumped however. I have two different ODBC connections to two
> different Caché DB's. They have the exact same structure and column names
> and types. I run a query against each of the connections and get back a
> Shared.DC.ZRDB.Results class in each case.
>
> Has anyone come up with code to combine the results? I would be much
> appreciative. If not, a pointer in the right direction would be helpful.

Hi Dale,

if I understand you correctly, you want to be able to UNION the two queries.
If that is the case then I'd be tempted to do this on the database side if
possible. Of course, Zope does make it easy to integrate the two result sets
using a PythonScript.

As you can interate through the objects you can easily create two lists and
combine them:

results = list(context.SQL1())
results += list(context.SQL2())

If performance is an issue then you should look at combining the results on
the db side.

Charlie
--
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
RE: Combine Result Sets [ In reply to ]
Charlie,

Thanks. I only WISH I could do it on the db side. As I don't have any control over the database (thank you vendor), I have to deal with it on the other side of an ODBC link. Ugh!

Although I am in the midst of working out a caching scheme to help speed things up a bit.

I will give this a try and hope it's not too bad a hit on me.

Thanks again,

Dale

P.S. mx.ODBC rocks!!

-----Original Message-----
From: Charlie Clark [mailto:charlie@egenix.com]
Sent: Friday, September 23, 2005 12:15 PM
To: Dale Hirt
Cc: zope-db@zope.org
Subject: Re: [Zope-DB] Combine Result Sets



On 2005-09-23 at 18:14:40 [+0200], Dale Hirt <dale@sbcltd.com> wrote:
> Hello,
>
> I have been searching both online and in this list's archives. I am still
> a bit stumped however. I have two different ODBC connections to two
> different Caché DB's. They have the exact same structure and column names
> and types. I run a query against each of the connections and get back a
> Shared.DC.ZRDB.Results class in each case.
>
> Has anyone come up with code to combine the results? I would be much
> appreciative. If not, a pointer in the right direction would be helpful.

Hi Dale,

if I understand you correctly, you want to be able to UNION the two queries.
If that is the case then I'd be tempted to do this on the database side if
possible. Of course, Zope does make it easy to integrate the two result sets
using a PythonScript.

As you can interate through the objects you can easily create two lists and
combine them:

results = list(context.SQL1())
results += list(context.SQL2())

If performance is an issue then you should look at combining the results on
the db side.

Charlie
--
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db