In Oracle / PLSQL, there is a trim () function that is useful for removing a certain character. The default is a blank (or empty space) character.
Simple syntax is as follows:
trim ([leading | trailing | both [trim_character]] trim_source)
The explanation:
leading = remove the trim_character character that is in front of trim_source
trailing = remove the trim_character character that is behind trim_source
both = remove the trim_character character that is in front and behind trim_source
Rule:
– if trim_character is not defined, the default is blank (blank space)
– if only trim_source is defined, then the default is both with trim_character as blank
– if trim_source is NULL, then this function will return NULL
Example:
ELECT TRIM('ASF') FROM DUAL; will return 'ASF' SELECT TRIM('' from 'ASF') FROM DUAL; will return 'ASF' SELECT TRIM(leading '' from 'ASF') FROM DUAL; will return 'ASF' SELECT TRIM(trailing '' from 'ASF') FROM DUAL; will return 'ASF' SELECT TRIM(both '' from 'ASF') FROM DUAL; will return 'ASF'