How to remove leading spaces in plsql
Hi folks, currently this below gives leading spaces after using 'RTRIM', is there any way i can improvise on this and remove those also if the value is ending with 0 i don't need the 'RTRIM' to remove that 0 since it is part of the solution
BEGIN
DBMS_OUTPUT.PUT_LINE(TO_CHAR(0.252345, '9990.99999999999999999999'));
DBMS_OUTPUT.PUT_LINE(RTRIM(TO_CHAR(0.252345, '9990.99999999999999999999'), 0));
END;
Output
0.25234500000000000000
0.252345
PS: I used RTRIM to prefix 0 before decimal point.
You should use FM
in your format to suppress leading space.
TO_CHAR(0.252345, 'FM9990D99999999999999999999')
Or better still, don't do this in SQL (or PL/SQL for that matter) at all, but handle display issues in your app or Website instead.
The decimal separator is D
in the format string, not .
by the way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.