🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.bazy-danych
Article #195688

Re: PostgreSQL - trigger pomija instrukcje

#195688
From: Andrzej Stróżyński
Date: Tue, 05 Nov 2019 11:46
32 lines
2041 bytes
W dniu 2019-11-03 o 23:18, Marek S pisze:
> Witam Was,
> 
> Mam kłopot ze zrozumieniem, co się dzieje. Otóż stworzyłem trigger:
> 
>          CREATE OR REPLACE FUNCTION admin.category_delete()
>              RETURNS TRIGGER AS
>                  $$
>                  BEGIN
>                      RAISE NOTICE 'Weight %, parent ID %', OLD.weight, 
> OLD.parent_id;
>                      UPDATE admin.category SET weight = weight - 1 WHERE 
> parent_id = OLD.parent_id AND weight > OLD.weight;
>                      RAISE NOTICE 'After update';
>                      RETURN OLD;
>                  END;
>                  $$
>          LANGUAGE plpgsql;
> 
> 
> Wywołuję go jako:
> 
> CREATE TRIGGER category_delete AFTER DELETE ON admin.category FOR EACH 
> ROW EXECUTE PROCEDURE admin.category_delete()
> 
[...]

Robisz UPDATE wiersza po jego usunięciu?

-- 
pozdrawiam
AS
Technical Details
Message-ID: <5dc16116$0$543$65785112@news.neostrada.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!wsisiz.edu.pl!goblin2!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
References: <qpnjmv$f6a$1@news.icm.edu.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!wsisiz.edu.pl!goblin2!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
Subject: Re: PostgreSQL - trigger pomija instrukcje
Newsgroups: pl.comp.bazy-danych
References: <qpnjmv$f6a$1@news.icm.edu.pl>
From: Andrzej Stróżyński
 <astrozynski@poczta_dot_onet.pl>
Date: Tue, 5 Nov 2019 12:46:30 +0100
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0
MIME-Version: 1.0
In-Reply-To: <qpnjmv$f6a$1@news.icm.edu.pl>
Lines: 32
Message-ID: <5dc16116$0$543$65785112@news.neostrada.pl>
Organization: Telekomunikacja Polska
NNTP-Posting-Host: 80.53.153.108
X-Trace: 1572954390 unt-rea-a-02.news.neostrada.pl 543 80.53.153.108:53604
X-Complaints-To: abuse@news.neostrada.pl
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit