This is very useful and interesting. I can see it's very useful. I am not sure if it's costly or not?
begin;
create temp table account_details(email text primary key, username text, password text);
insert into account_details(email, username, password) values('a.com','b','c'),('b.com','d','e');
commit;
CREATE TRIGGER trigger_update_account_details
AFTER UPDATE ON account_details
FOR EACH ROW
WHEN (OLD.email IS DISTINCT FROM NEW.email
OR OLD.username IS DISTINCT FROM NEW.username
OR OLD.password IS DISTINCT FROM NEW.password)
EXECUTE PROCEDURE notify_insert_account_details();
________________________________________________________________________
What possible PROCEDURE notify_insert_account_details() can be.
The following is my immature test code.
CREATE OR REPLACE FUNCTION notify_insert_account_details()
RETURNS trigger
LANGUAGE plpgsql AS
$$
BEGIN
RAISE NOTICE 'hello world';
END
$$;
_______________________________________________________
when I update then error occurs. the update clause didn't execute. the function did fired.
NOTICE: hello world
ERROR: control reached end of trigger procedure without RETURN
CONTEXT: PL/pgSQL function notify_insert_account_details()
______________________________________________
I am wondering how sophisticated this procedure/function notify_insert_account_details() can become, let's say linked within 3 table.
Can anyone showcase an example/demo?