- fix wrong usage of TRIM in postgresql, must use TRUNC - refactor to use safer methods throwing error on DB exceptions