Creating trigger with optional arg?

From: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
To: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Creating trigger with optional arg?
Date: 2020-07-22 16:48:49
Message-ID: CAOC+FBX5WP-ciFA0gd_hvG-AKB4Huopr9xttN6D1MTKR6P6e=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Is it possible to have a variable number of elements in TG_ARGV in a
trigger?

Arguments 1-3 are required, and I'd like a NULL check on TG_ARGV[4] as an
optional message, so it could be called in one of two ways:

create trigger tg_mytrig after insert on mytable for each row execute
procedure my_trigger('opt1', 'opt2', 'opt3');
create trigger tg_mytrig after insert on mytable for each row execute
procedure my_trigger('opt1', 'opt2', 'opt3', 'optional opt4');

With some kind of null check on TG_ARGV[4] inside the trigger.

--
Wells Oliver
wells(dot)oliver(at)gmail(dot)com <wellsoliver(at)gmail(dot)com>

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2020-07-22 16:58:51 Re: Creating trigger with optional arg?
Previous Message jian xu 2020-07-21 23:48:14 Re: checkpoint process use too much memory