This is maybe obvious for some experienced PostgreSQL user but people coming from other database may be pleasantly surprised with this construct:

IF EXISTS( select ... from table where ....) THEN

END IF;