pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Davide Romanini <romaz@libero.it>
To: pgsql-odbc@postgresql.org
Subject: About rules on views and M$ Access
Date: Fri, 17 Jan 2003 15:21:01 +0100
Message-ID: <3E28114D.4050203@libero.it> (raw)

Hi,

I've some problems releted to updating columns of a view, from M$ Access 
through ODBC. Well let me explain.

I've a view that takes data from two different tables and have some 
calculated columns.
I simply want to modify data of some of the non-calculated columns, so I 
wrote a rule that on the UPDATE
event on the view performs another UPDATE on the table I want to modify.

This is the view:

CREATE VIEW ordini_emessi_view AS
   SELECT "Dettagli Ordini Emessi"."Ordine numero",
                  "Dettagli Ordini Emessi"."IDArticolo",
                  "Dettagli Ordini Emessi"."Quantità",
                  "Dettagli Ordini Emessi"."QuantitàEvasa",
                  "Anagrafica Articoli Tab"."CodiceAcquisto",
                  ("Costo" * (1 - ("Sconto" / 100))) AS "CostoEffettivo",
                  "Anagrafica Articoli Tab"."MinimoAcquisto",
                  "Anagrafica Articoli Tab"."Collegamento",
                  "Descrizione degli articoli"."Descrizione",
                  "Dettagli Ordini Emessi"."PrezzoUnit",
                  "Descrizione degli articoli"."Unità di Fatturazione" 
AS "UDM"
  FROM    (("Anagrafica Articoli Tab" JOIN "Dettagli Ordini Emessi"
                               ON (("Anagrafica Articoli 
Tab"."IDArticolo" = "Dettagli Ordini Emessi"."IDArticolo")))
                     JOIN "Descrizione degli articoli"
                               ON (("Anagrafica Articoli 
Tab"."Collegamento" = "Descrizione degli articoli"."IDART")));

I'd want to modify only the columns of "Dettagli Ordini Emessi" so the 
rule is:

CREATE OR REPLACE RULE ordini_emessi_update AS ON UPDATE TO 
ordini_emessi_view
DO INSTEAD
   UPDATE "Dettagli Ordini Emessi" SET "Ordine numero"=NEW."Ordine numero",
                                                                
"IDArticolo"=NEW."IDArticolo", "Quantità"=NEW."Quantità",
                                                                
"QuantitàEvasa"=NEW."QuantitàEvasa", "PrezzoUnit"=NEW."PrezzoUnit"
    WHERE "Ordine numero"=OLD."Ordine numero" AND 
"IDArticolo"=OLD."IDArticolo";

It all works fine if I do updates in this form:

UPDATE ordini_emessi_view SET  field=something, ...
   WHERE "Ordine numero"=something AND "IDArticolo"=something;

I've problems using M$ Access because it sends UPDATES with a lot of 
fields in the WHERE clause. It always includes the
calculated column "CostoEffettivo" that makes PostgreSQL updating nothing:

UPDATE "ordini_emessi_view" SET "Quantità"='360'::float4
WHERE "Ordine numero" = 620 AND "IDArticolo" = 3170
AND "Quantità" = '350'::float4 AND "QuantitàEvasa" = '360'::float4
AND "CostoEffettivo" = '1.44232004547119'::double precision   --This 
line makes problems!
AND "MinimoAcquisto" = '18'::float4 AND "Collegamento" = 2793
AND "PrezzoUnit" = '1.4423'::float8 AND "UDM" = 'mq';

Please note that if I comment that line and send the query manually to 
PG it works perfectly.
I think that when PG reads this SQL it looks in the view for a row 
satisfacting the WHERE conditions, then
if it founds it performs the update, elsewhere it does nothing.
But it simply doesn't find any row with 
"CostoEffettivo"='1.44232004547119' and this is probably due to internal 
handling of double precision numbers, I don't know exactly why. The 
query successes if I cast the column "CostoEffettivo" as text.
Remember anyway that I can't change the queries the Access sends to ODBC!

Please, if you have suggestions about solving this problem, tell me!

Regards, Romaz






view thread (4+ messages)  latest in thread

Message-ID: <3E28114D.4050203@libero.it>
Permalink:  ../3E28114D.4050203@libero.it/
Also on:    postgresql.org/message-id/3E28114D.4050203@libero.it

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: romaz@libero.it
  Subject: Re: About rules on views and M$ Access
  In-Reply-To: <3E28114D.4050203@libero.it>
  References: <3E28114D.4050203@libero.it>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox