Re: Call a Normal function inside a Trigger Function
От | Adrian Klaver |
---|---|
Тема | Re: Call a Normal function inside a Trigger Function |
Дата | |
Msg-id | a7e9cf7a-ae6e-e3c3-4c72-d6adfc523967@aklaver.com обсуждение исходный текст |
Ответ на | Re: Call a Normal function inside a Trigger Function (FOUTE K. Jaurès <jauresfoute@gmail.com>) |
Ответы |
Re: Call a Normal function inside a Trigger Function
|
Список | pgsql-general |
On 4/16/23 11:47, FOUTE K. Jaurès wrote: > Can I have an example please? Or a link create table trg_test (id integer, fld_1 varchar, fld_2 boolean); CREATE OR REPLACE FUNCTION public.child_fnc(token character varying) RETURNS void LANGUAGE plpgsql AS $function$ BEGIN IF token = 'yes' THEN RAISE NOTICE 'Child'; END IF; END; $function$ ; CREATE OR REPLACE FUNCTION public.parent_fnc() RETURNS trigger LANGUAGE plpgsql AS $function$ BEGIN RAISE NOTICE 'Id is %', NEW.id; RAISE NOTICE 'Fld_1 is %', NEW.fld_1; RAISE NOTICE 'Parent'; PERFORM child_fnc('yes'); RETURN NEW; END; $function$ ; create trigger test_trg before insert on trg_test for each row execute function parent_fnc(); insert into trg_test values (1, 'dog', 'f'); NOTICE: Id is 1 NOTICE: Fld_1 is dog NOTICE: Parent NOTICE: Child INSERT 0 1 > > On Sun, 16 Apr 2023, 17:08 Pavel Stehule, <pavel.stehule@gmail.com > <mailto:pavel.stehule@gmail.com>> wrote: > > Hi > > > ne 16. 4. 2023 v 16:15 odesílatel FOUTE K. Jaurès > <jauresfoute@gmail.com <mailto:jauresfoute@gmail.com>> napsal: > > Hello, > > Is it possible to call a function inside a trigger function ? > Any idea or link are welcome. Thanks in advance > > > sure, there is not any limit. > > Regards > > Pavel > > > Best Regards > -- > Jaurès FOUTE > -- Adrian Klaver adrian.klaver@aklaver.com
В списке pgsql-general по дате отправления: