Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 008D59FB2B4 for ; Wed, 10 Oct 2007 05:07:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 67530-01 for ; Wed, 10 Oct 2007 05:07:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from wdscexfe01.sc.wdc.com (wdscexfe01.sc.wdc.com [129.253.170.53]) by postgresql.org (Postfix) with ESMTP id 572499FB298 for ; Wed, 10 Oct 2007 05:07:26 -0300 (ADT) Received: from wdmyexbe03.my.asia.wdc.com ([129.253.105.55]) by wdscexfe01.sc.wdc.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 10 Oct 2007 01:07:10 -0700 Received: from 129.253.107.165 ([129.253.107.165]) by wdmyexbe03.my.asia.wdc.com ([129.253.105.55]) with Microsoft Exchange Server HTTP-DAV ; Wed, 10 Oct 2007 08:07:07 +0000 Received: from neuromancer by 129.253.105.55; 10 Oct 2007 16:07:15 +0800 Subject: pgodbc + Excel + msquery + background refresh From: Ow Mun Heng To: pgsql-odbc@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Wed, 10 Oct 2007 16:07:14 +0800 Message-Id: <1192003634.442.17.camel@neuromancer.home.net> Mime-Version: 1.0 X-Mailer: Evolution 2.10.2 X-OriginalArrivalTime: 10 Oct 2007 08:07:10.0707 (UTC) FILETIME=[8F096C30:01C80B14] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.067 tagged_above=0 required=5 tests=AWL=0.599, BAYES_00=-2.599, RCVD_NUMERIC_HELO=2.067 X-Spam-Level: X-Archive-Number: 200710/13 X-Sequence-Number: 9197 Just wonder if anyone here uses Excel to connect to PG via ODBC. I'm using it extensively as my platform to get data from PG/MSSQL directly into excel. (Excel uses the msqry32.exe file which is like a stripped down sql query tool and returns data directly into excel) When using mssql, connecting from excel to mssql, I can get the query to run in the background. Hence, a long running query will not interfere with normal running of other excel works. Eg: Create new sheets, graphing etc. However, when trying to achieve the same thing using PG, somehow it either : 1. PG/PG_ODBC doesn't parse/handle the request to do the query in the background 2. I'm doing something wrong. I'm partial to #1 as it works find on mssql. Here's a sample query macro which you can stick into Excel. (alt-F11, Module, Insert-New-Modules) The Keyword here is "Refresh BackgroundQuery = True" Sub macro1() SQL = "Select * from public.tablename limit 5000" With ActiveSheet.QueryTables.Add(Connection:=Array(Array("ODBC;DRIVER={PostgreSQL Unicode};DATABASE=public;SERVER=127.0.0.1;PORT=5432;UID=pguser;PWD=pguser")), Destination:=Range("A1")) .CommandText = SQL .Name = "" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh BackgroundQuery:=True End If End With End Sub I think this is like the last hurdle for me from moving from mssql to PG. Thanks and hopefully, there will be someone who uses it this way.