Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A3A01475F39 for ; Fri, 17 Jan 2003 09:19:50 -0500 (EST) Received: from smtp2.libero.it (smtp2.libero.it [193.70.192.52]) by postgresql.org (Postfix) with ESMTP id 15DEA475E82 for ; Fri, 17 Jan 2003 09:19:50 -0500 (EST) Received: from libero.it (151.26.183.86) by smtp2.libero.it (6.7.015) id 3E0C6F60007EC05B for pgsql-odbc@postgresql.org; Fri, 17 Jan 2003 15:19:53 +0100 Message-ID: <3E28114D.4050203@libero.it> Date: Fri, 17 Jan 2003 15:21:01 +0100 From: Davide Romanini User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.0.1) Gecko/20020826 X-Accept-Language: it, en, en-us MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: About rules on views and M$ Access Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/68 X-Sequence-Number: 2567 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