How can I pass an expression as an argument when calling a trigger function?
create trigger my_trigger
after insert on my_table
for each row
execute function trigger_job(
'job_name',
(json_build_object(
'foo', current_setting('foo', true),
'bar', current_setting('bar', true)
))
);
I know how to call a "normal" function with an expression as an argument, but I can't get it to work calling a function from the trigger. I also know how to read the passed arguments from TG_ARGV[] in the trigger function, but that's beyond this question.
I also tried something simple like:
create trigger my_trigger
after insert on my_table
for each row
execute function trigger_job(
'job_name',
(true)
);
But I still get the error:
ERROR: syntax error at or near "("
LINE 6: (true)
^
Update: I am now using an intermediate function. The trigger calls the intermediate function with the single text parameter. That intermediate function builds the second argument and calls the final trigger_job
function with both arguments. Simple.