trigger on delete/field update

From: Ruslan R(dot) Laishev <zator(at)yandex(dot)ru>
To: pgsql-novice(at)postgresql(dot)org
Subject: trigger on delete/field update
Date: 2017-10-16 14:27:38
Message-ID: 1880941508164058@web15o.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

<div><span style="font-family:courier new,monospace;">Hi All!</span></div><div> </div><div><span style="font-family:courier new,monospace;">I have tried to set a flag ('deleted' ) instead of actual record deletion, so I have tried to accomplish it with next piece of code in the trigger:</span></div><div> </div><div><div><span style="font-family:courier new,monospace;">BEGIN</span></div><div><span style="font-family:courier new,monospace;">/*</span></div><div><span style="font-family:courier new,monospace;">**  Description: disable  deletion of the rows from the table,</span></div><div><span style="font-family:courier new,monospace;">**    instead we set .deleted flag to 1</span></div><div><span style="font-family:courier new,monospace;">*/</span></div><div> </div><span style="font-family:courier new,monospace;">        IF (TG_OP = 'DELETE') THEN</span><div><span style="font-family:courier new,monospace;">         UPDATE v.comps SET deleted = 1 WHERE v.comps.id = OLD.id;</span></div><div><span style="font-family:courier new,monospace;">                RETURN NULL;</span></div><div><span style="font-family:courier new,monospace;">        END IF;</span></div><div> </div><div><span style="font-family:courier new,monospace;">END;</span></div><div> </div><div> </div><div><span style="font-family:courier new,monospace;">DELETE row on the table v does not generate any error, but row still here and 'deleted' field has not been set to 1 as expected.</span></div><div><span style="font-family:courier new,monospace;">So, what I'm need to check ?</span></div><div> </div><div> </div><div> </div><div><span style="font-family:courier new,monospace;">TIA.</span></div><div> </div></div><div><span style="font-family:courier new,monospace;">-- </span></div><div><span style="font-family:courier new,monospace;">С уважением,<br />Ruslan R. Laishev</span></div><div><span style="font-family:courier new,monospace;">OpenVMS bigot, natural born system/network progger, C contractor.</span></div><div><span style="font-family:courier new,monospace;">+79013163222</span></div><div><span style="font-family:courier new,monospace;">+79910009922</span></div><div> </div>

Attachment Content-Type Size
unknown_filename text/html 2.2 KB

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Adarsh Jaiswal 2017-10-16 14:31:20 Re: The server does not listen
Previous Message manno_it 2017-10-16 14:21:51 Re: The server does not listen