I have an input record with a variable number of trailing spaces after the last alpha character. How can I drop these trailing blanks and shorten up the record?
RTRIM is what you are looking for. This is what Oracle Documentation says -
Purpose
RTRIM returns char, with all the rightmost characters that appear in set removed; set defaults to a single blank. If char is a character literal, you must enclose it in single quotes. RTRIM works similarly to LTRIM.
Example
SELECT RTRIM('BROWNINGyxXxy','xy') "RTRIM e.g."
FROM DUAL;
# ------------------------------------------------------------------------
#
# Function to "trim" leading and trailing spaces from a string NOT
# disturbing the "embedded" spaces.
#
function trim(str)
{
# nsub1=gsub("^[[:space:]]+|[[:space:]]+$", "", $i);
nsub1=sub("^[ ]*", "", str);
nsub2=sub("[ ]*$", "", str);
return str;
}
# ------------------------------------------------------------------------
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.