From: | Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz> |
---|---|
To: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Detection of which attributes should get set in update trigger |
Date: | 2023-11-10 15:41:46 |
Message-ID: | e4bc5896-86f9-44a2-8a97-9aa2324bc84c@gelassene-pferde.biz |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks for the reply. I confirm the behaviour. Your explanation makes
sense if I consider having read that with an update the is a complete
new record version written.
Am 10.11.2023 um 14:35 schrieb David G. Johnston:
> On Friday, November 10, 2023, Thiemo Kellner
> <thiemo(at)gelassene-pferde(dot)biz> wrote:
>
> Hi all
>
> I have a view, that is a join over 4 tables (the setup of the rule
> question). I want to update the central table over the view (by an
> instead-of trigger). How can I determine, whether an attribute
> should get set to NULL, "new.XYZ is null" or whether it should be
> left alone. Is there a leave-me-alone function determining,
> whether an attribute is in the set clause of an update statement.
> I am thinking along the line code in the trigger function like
>
> update TABLE
> set XYZ = case
> when leave-me-alone (new.XYZ) then old.XYZ
> else new.XYZ
> end;
>
> And what about the where condition... hm, guess I am a bit confused.
>
>
> IIUC, The NEW record is complete, with every value as it should be in
> the newly saved tuple. There is no leave-me-alone concept. You don’t
> get to know if the column was specified or not in the update command.
>
> David J.
>
From | Date | Subject | |
---|---|---|---|
Next Message | pf | 2023-11-12 00:12:14 | Aren't regex_*() functions built-in? |
Previous Message | David G. Johnston | 2023-11-10 13:35:01 | Re: Detection of which attributes should get set in update trigger |