Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id E24FDF765A for ; Wed, 11 Apr 2012 21:25:13 -0300 (ADT) Received: from rs135.luxsci.com ([74.205.104.184]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SI7qa-0001yb-Gb for pgsql-odbc@postgresql.org; Thu, 12 Apr 2012 00:25:13 +0000 Received: from [192.168.0.100] (50-52-20-202.cral.id.frontiernet.net [50.52.20.202]) (authenticated bits=0) by rs135.luxsci.com (8.13.8/8.13.8) with ESMTP id q3C0Ovwf014664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 11 Apr 2012 19:24:59 -0500 Message-ID: <4F8620DE.5070109@infowerks.com> Date: Wed, 11 Apr 2012 17:25:02 -0700 From: Ken Benson User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: Re: UPDATE table via ODBC fails. References: <4F85FF40.5080802@infowerks.com> In-Reply-To: <4F85FF40.5080802@infowerks.com> Content-Type: multipart/alternative; boundary="------------070108050104040007030509" X-Lux-Comment: Message q3C0Ovwf014664 sent by user #92247 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201204/10 X-Sequence-Number: 10824 This is a multi-part message in MIME format. --------------070108050104040007030509 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit UPDATE: This must have something to do with the multiple table involvement. I modified my 'insert' command to include the updated field on the initial insert. INSERT INTO tmp_rxpurge (rxnum,dt_wrt,dt_lastfill,b_purge) SELECT "RXNUM","DATE",rf.dt_lastfill,'f' FROM rx LEFT JOIN (SELECT "RXNUM" AS rxnum, Max("DATE") as dt_lastfill FROM transactions GROUP BY "RXNUM") as rf on rf.rxnum=rx."RXNUM" Then - created three additional update steps ... they all worked via the ODBC connector... 1. UPDATE tmp_rxpurge SET dt_lastact=dt_wrt 2. UPDATE tmp_rxpurge SET dt_lastact=dt_lastfill where dt_lastfill IS NOT NULL and dt_lastfill > dt_lastact 3. UPDATE tmp_rxpurge SET b_purge='t' where dt_lastact < '2010-01-01' I'm still puzzled why the first method didn't work. Ken On 4/11/2012 3:01 PM, Ken Benson wrote: > I have a fairly straightforward routine which uses an ODBC connection > to do 4 steps: > > * DROP TABLE IF EXISTS tmp_rxpurge > * CREATE TABLE tmp_rxpurge (rxnum VARCHAR(300),dt_wrt > DATE,dt_lastfill DATE,dt_lastact DATE, b_purge BOOLEAN) > * INSERT INTO tmp_rxpurge (rxnum,dt_wrt,b_purge) SELECT > "RXNUM","DATE",'f' FROM rx > * UPDATE tmp_rxpurge as t SET dt_lastfill = rf.dt_lastfill FROM > (SELECT "RXNUM" AS rxnum, Max("DATE") as dt_lastfill FROM > transactions GROUP BY "RXNUM") as rf WHERE rf.rxnum=t.rxnum > > > The first three commands are executed perfectly as expected. > The update fails to do anything. > There is no error generated. > I have enabled 'logging' in the ODBC connector - and I don't see > anything out of the ordinary in the short-log. (The long-log - I have > no idea what all that stuff means.) > > If I copy that last command into a psql window - it executes - and > works fine. > > But - it will not work via the ODBC connector. > > What's going on? > > Ken --------------070108050104040007030509 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit UPDATE:

This must have something to do with the multiple table involvement.

I modified my 'insert' command to include the updated field on the initial insert.
INSERT INTO tmp_rxpurge (rxnum,dt_wrt,dt_lastfill,b_purge) 
SELECT "RXNUM","DATE",rf.dt_lastfill,'f' 
FROM rx 
LEFT JOIN  (SELECT "RXNUM" AS rxnum, Max("DATE")  as dt_lastfill FROM transactions GROUP BY "RXNUM")
            as rf on rf.rxnum=rx."RXNUM"


Then - created three additional update steps ... they all worked via the ODBC connector...
  1. UPDATE tmp_rxpurge SET dt_lastact=dt_wrt
  2. UPDATE tmp_rxpurge SET dt_lastact=dt_lastfill where dt_lastfill IS NOT NULL and dt_lastfill > dt_lastact
  3. UPDATE tmp_rxpurge SET b_purge='t' where dt_lastact < '2010-01-01'

I'm still puzzled why the first method didn't work.

Ken

On 4/11/2012 3:01 PM, Ken Benson wrote:
I have a fairly straightforward routine which uses an ODBC connection to do 4 steps:

  • DROP TABLE IF EXISTS tmp_rxpurge
  • CREATE TABLE tmp_rxpurge (rxnum VARCHAR(300),dt_wrt DATE,dt_lastfill DATE,dt_lastact DATE, b_purge BOOLEAN)
  • INSERT INTO tmp_rxpurge (rxnum,dt_wrt,b_purge) SELECT "RXNUM","DATE",'f' FROM rx
  • UPDATE tmp_rxpurge as t SET dt_lastfill = rf.dt_lastfill FROM (SELECT "RXNUM" AS rxnum, Max("DATE") as dt_lastfill FROM transactions GROUP BY "RXNUM") as rf WHERE rf.rxnum=t.rxnum

The first three commands are executed perfectly as expected.
The update fails to do anything.
There is no error generated.
I have enabled 'logging' in the ODBC connector - and I don't see anything out of the ordinary in the short-log. (The long-log - I have no idea what all that stuff means.)

If I copy that last command into a psql window - it executes - and works fine.

But - it will not work via the ODBC connector.

What's going on?

Ken
--------------070108050104040007030509--