Dear all PostgreSQL xperts!

Hi, I am newbie in PostgreSQL. I am currently developing an app that use PostgreSQL as a BackEnd Database.
Now I am having problem with the function trigger since last week.

Here's the case:

create table nr_tr (tr_type character(3), period character(6), nr_tr integer);
create table h_trsale(nr_tr integer, sale_dt datetime, desc text);
create table h_trbuy...