From: | Luca Ferrari <fluca1978(at)infinito(dot)it> |
---|---|
To: | Sajeev Mayandi <Sajeev_Mayandi(at)symantec(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: to know what columns are getting updated |
Date: | 2013-07-30 06:12:27 |
Message-ID: | CAKoxK+5ztucRdEM8xHLtQfSRjqcGG_A3ifeJVGGie8_98EsJmw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Jul 30, 2013 at 6:05 AM, Sajeev Mayandi
<Sajeev_Mayandi(at)symantec(dot)com> wrote:
> Hi,
>
> I have bunch of rules created for tables to implement upsert functionality.
> My problem is our tables gets updated from multiple places , non
> –necessarily with the same no of columns. I want to figure out columns are
> being asked to be updated
>
> E.g. The rule for the the table base-table is
>
> CREATE OR REPLACE RULE base-table-rule AS
> ON INSERT TO base-table
> WHERE (EXISTS ( SELECT 1
> FROM base-table
> WHERE bas-table::x1 = new.x1 ))
> DO INSTEAD UPDATE base-table SET x1=new.x1,x2=new.x2,x3
> =new.x3,x4=new.x4
> WHERE base-table.x1= new.x1;
>
I suppose this is for loggin purposes, so I would suggest to DO ALSO
and add a debuggin statement, like for instance a log entry in a table
or a raise instruction. Could it solve the problem?
Anyway it seems to me there's a design problem: essentially you are
converting an insert on duplicated key into an update, would not be
better to use the right statement for the right purpose?
Luca
From | Date | Subject | |
---|---|---|---|
Next Message | Raghavendra | 2013-07-30 06:21:35 | Re: how to get UPDATEXML function in postgresql as it works in oracle |
Previous Message | Dann Corbit | 2013-07-30 05:15:06 | Re: Fastest Index/Algorithm to find similar sentences |