Click here to Skip to main content
14,391,651 members
Rate this:
Please Sign up or sign in to vote.
See more:

I have a table "Documents"(id serial PK, date timestamp, name varchar, description varchar);
And another table "News"(id serial PK, date timestamp, details varchar).
*In column News.details will be the data from column Documents.description.

I would like to create a function that:
When I update the row in Documents, the row in News will be updated too.
The function uses an After Trigger.

So far I managed to test the following function, it returns no errors, but it doesn`t update the row in News:

create function update_news()
returns trigger as
if (TG_OP = 'UPDATE') then
	update News  
	set details = NEW.description
	where details = OLD.description;
return NEW;
	end if;	
language plpgsql;

The trigger:
create trigger trig_news
after update on Documents for each row execute procedure update_news();

I am working with PostgreSQL.
I would like to ask if anyone can help, or share some ideas, please.

Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100