If running against Optiq, change "RTRIM(...)" to "TRIM(LEADING ' ' FROM ...)".