There are more complex examples in in src/test/regress/regress.c
and in contrib/spi.

Here is a very simple example of trigger usage. Function trigf
reports the number of tuples in the triggered relation ttest and
skips the operation if the query attempts to insert NULL into x
(i.e - it acts as a NOT NULL constraint but doesn't abort the
transaction).