2
I need to update an X table whenever there is a change in table Y. I have found numerous examples of how to save the changed records in table Y, both when deleting a record from table X and when it is changed or inserted, but my need is not to create a new row in table Y whenever a record is changed in table X, i just need to change the line that has the same code and that had the information changed.
Example:
I have two tables, where there are two columns, id_client and client name_name, what I need is that when the client name is changed in table 01, automatically the client name in table 02 that has the same id.
I found how to add a new line with the following command:
create or replace function salvaexcluido()
returns trigger as
$BODY$ begin
insert into bk_transportadora values (old.codigo, old.nome, old.status);
return null;
end;$BODY$
language 'plpgsql'
In this case a new line would be added whenever a record was deleted. If you have any ideas it would be great.