From ken@infowerks.com Wed Apr 11 22:01:47 2012 Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id AB6CCF765A for ; Wed, 11 Apr 2012 19:01:47 -0300 (ADT) Received: from rs135.luxsci.com ([74.205.104.184]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SI5bm-0008HC-DA for pgsql-odbc@postgresql.org; Wed, 11 Apr 2012 22:01:47 +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 q3BM1VqD031970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 11 Apr 2012 17:01:32 -0500 Message-ID: <4F85FF40.5080802@infowerks.com> Date: Wed, 11 Apr 2012 15:01:36 -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: UPDATE table via ODBC fails. Content-Type: multipart/alternative; boundary="------------020905000209090906010704" X-Lux-Comment: Message q3BM1VqD031970 sent by user #92247 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201204/9 X-Sequence-Number: 10823 This is a multi-part message in MIME format. --------------020905000209090906010704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------020905000209090906010704 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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
--------------020905000209090906010704-- From ken@infowerks.com Thu Apr 12 00:25:13 2012 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-- From richard.broersma@gmail.com Fri Apr 13 15:22:18 2012 Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 6266515A7DE1 for ; Fri, 13 Apr 2012 12:22:18 -0300 (ADT) Received: from mail-wg0-f50.google.com ([74.125.82.50]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SIiKH-0004Vk-09 for pgsql-odbc@postgresql.org; Fri, 13 Apr 2012 15:22:18 +0000 Received: by wgbds12 with SMTP id ds12so3069244wgb.19 for ; Fri, 13 Apr 2012 08:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=9HbWd7IKp1uDG1CJPT60exbWxVxdCqP2hKGrRU/iGyw=; b=oobnBpe08vA0xdW7vr9Yjm26pCWJ4S6sT9N4Ed2xXoa/g5NVMwDpcHqSLtpcr6+HHE frkpA+aGQuC3xPGRqloQAsII9aAf/8tk9NItAu7jc9EW0nWc/iX9lFmKvUEc1VptBRsZ y+UAEZ7SaRt8GZnynsiTKyM0tZRaIuiBHYcWmC8khuYUtfj7dksbFz7Xhnq5QZCLrUGk Ga0KiKhwYG4rOt0uDBrwUhD+QMH69ET1fzlS7YlFTpjUO3+Xiv59BmA4XEUseiSv40j6 WrO0Vffa/DlSZJ68yLZx19WG6bEGhny3q1QmCkzDgZuwl5nOFD1GdfQ7ZfF52efZET5l svxQ== MIME-Version: 1.0 Received: by 10.180.96.228 with SMTP id dv4mr5627402wib.14.1334330524009; Fri, 13 Apr 2012 08:22:04 -0700 (PDT) Received: by 10.223.78.195 with HTTP; Fri, 13 Apr 2012 08:22:03 -0700 (PDT) In-Reply-To: <4F85FF40.5080802@infowerks.com> References: <4F85FF40.5080802@infowerks.com> Date: Fri, 13 Apr 2012 08:22:03 -0700 Message-ID: Subject: Re: UPDATE table via ODBC fails. From: Richard Broersma To: Ken Benson Cc: pgsql-odbc@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201204/14 X-Sequence-Number: 10828 On Wed, Apr 11, 2012 at 3:01 PM, Ken Benson wrote: > 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 > 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.) You'll find that reading the logs produced by the PostgreSQL server to be much more informative about the miss behavior your experiencing. Can you post the logs generated by PostgreSQL, when you attempt this UPDATE statement? -- Regards, Richard Broersma Jr.