In PostgreSQL, I'm trying to create a trigger that passes an argument to a function, but it appears that this operation looks for a function whose signature has zero arguments:
ERROR: function create_rec_if_needed() does not exist:
CREATE TRIGGER after_update_winks AFTER UPDATE ON winks
FOR EACH ROW
WHEN (NEW.counter > 3)
EXECUTE PROCEDURE create_rec_if_needed(NEW.id, 'Wink')
When I list extant functions, I can see my 2-argument function. Here's the output of \df
:
List of functions
Schema | Name | Result data type | Argument data types
--------+-------------------------+---------------------------+-------------------------------------------------
public | create_rec_if_needed | void | rec_id integer, rec_type text
Can anyone shed a bit of light on why my trigger isn't making use of the existing function? Is there an alternative design I should use to reach my goal? My aim is for multiple tables to have a trigger that calls the function create_rec_if_needed
, and in each case, the trigger must supply the id of the record and a table-specific string.