
-- create table S (id integer, val text);
-- create table T (s integer, value text);

create or replace function
   check_T_update_fk() returns trigger
as $$
begin
    perform * from S where s.id = new.s;
    if (not found) then
	raise NOTICE 'Invalid T.s value';
        return old;
    else
        return new;
    end if;
end;
$$ language plpgsql;

create trigger T_fk_update_check
before update on T
for each row execute
procedure check_T_update_fk();
