Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id EE91EB5DCAE for ; Tue, 25 Oct 2011 05:00:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 13045-09 for ; Tue, 25 Oct 2011 07:59:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-yw0-f46.google.com (mail-yw0-f46.google.com [209.85.213.46]) by mail.postgresql.org (Postfix) with ESMTP id 71203B5DC5F for ; Tue, 25 Oct 2011 04:59:58 -0300 (ADT) Received: by ywm3 with SMTP id 3so243002ywm.19 for ; Tue, 25 Oct 2011 00:59:58 -0700 (PDT) Received: by 10.151.59.20 with SMTP id m20mr16702232ybk.39.1319529598108; Tue, 25 Oct 2011 00:59:58 -0700 (PDT) Received: from ?IPv6:2001:44b8:6109:9f00:2a0:c9ff:fe6e:ed8f? (2001-44b8-6109-9f00-02a0-c9ff-fe6e-ed8f.static.ipv6.internode.on.net. [2001:44b8:6109:9f00:2a0:c9ff:fe6e:ed8f]) by mx.google.com with ESMTPS id e4sm70983622ani.12.2011.10.25.00.59.56 (version=SSLv3 cipher=OTHER); Tue, 25 Oct 2011 00:59:57 -0700 (PDT) Message-ID: <4EA66C78.3020600@ringerc.id.au> Date: Tue, 25 Oct 2011 15:59:52 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Thunderbird/3.1.9 MIME-Version: 1.0 To: Rich CC: pgsql-sql@postgresql.org Subject: Re: How to write sql to access another odbc source. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201110/75 X-Sequence-Number: 35959 On 19/10/11 22:08, Rich wrote: > I have a mumps database with an ODBC connection so I can write queries > from other databases. How can I write a sql in Postgresql to access > this table to use in my Postgresql reports? Use dbi-link to make an ODBC connection to the other database. Either copy the data into a PostgreSQL table for processing, or make a view over the dbi-link function call to query the data each time. The latter option is slow, but requires no periodic refreshing of the copied table. If you're on PostgreSQL 9.1 I'd recommend copying the data from the other database via dbi-link into an unlogged table. See: http://pgfoundry.org/projects/dbi-link and the documentation for the dbi-link contrib module in your version of PostgreSQL. Hopefully in 9.2 the odbc foreign data wrapper will be working and ready for general use, in which case you'll be able to do it even more easily using ODBC FDW (SQL/MED). -- Craig Ringer