>If (coalesce(terminal, '') <> '') then No need for coalesce since <null> is an unknown state and compared with a value it neither returns true nor false. Hence, I suspect
if (trim(terminal) > '') to be equivalent to if (((CHAR_LENGTH(trim(terminal))>0) and (terminal is not null)) Set
