The answer to a decade-old StackOverflow question was helpful for me. However, I was unable to write an equivalent function and trigger in "standard" SQL, i.e. where the language
parameter specifies sql
instead of plpgsql
. The hangup appears to be that functions written in standard SQL can't return triggers, though this appears to be required for functions called by triggers in PostgreSQL:
The trigger function must be declared as a function taking no arguments and returning type trigger.
So attempting...
create function func_dummy()
returns trigger as
'update tbl_dummy
set update_date = current_timestamp;'
language sql;
results in:
ERROR: SQL functions cannot return type trigger
SQL state: 42P13
How can the PostgreSQL-specific function and trigger in the original SO answer be rewritten using "standard" SQL?