I need to update an X table whenever there are any changes in the Y table. I have found numerous examples of how to save the changed records in the Y table, both when a record of the X table is deleted and when it is changed or inserted, but my need is not to create a new row in the Y table whenever a record is changed in table X , I need only change the line that has the same code and that had the information changed.
Example:
I have two tables, where there are two columns, customer_id and customer_name, what I need is that when the customer name is changed in table 01, the customer name in table 02 that has the same id is automatically changed. p>
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 any record was deleted. If you have any ideas, it would be great.