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@xxxxxxxxx
<mailto:pavel.stehule@xxxxxxxxx>> wrote:
Hi
ne 16. 4. 2023 v 16:15 odesílatel FOUTE K. Jaurès
<jauresfoute@xxxxxxxxx <mailto:jauresfoute@xxxxxxxxx>> 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@xxxxxxxxxxx