From: | Sajeev Mayandi <Sajeev_Mayandi(at)symantec(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | to know what columns are getting updated |
Date: | 2013-07-30 04:05:16 |
Message-ID: | CE1BE0CC.4C4E0%sajeev_mayandi@symantec.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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;
1) user 1 comes with the below insert
Insert into base-table(x1,x2,x3,x4) values(v1,v2,v3,v4);
2) user 2 comes with the below insert
Insert into base-table(x1,x2) values(v1,v2);
Since user 2 uses only x1 and x2 as its column the rule replaces x3 and x4 with null.
Is there a way to figure out that only x1 and x2 is being asked for an updating. In the above example column x1 is the primary key.
Thanks,
Sajeev
From | Date | Subject | |
---|---|---|---|
Next Message | Dann Corbit | 2013-07-30 05:15:06 | Re: Fastest Index/Algorithm to find similar sentences |
Previous Message | Sergey Konoplev | 2013-07-30 03:54:25 | Re: Fastest Index/Algorithm to find similar sentences |