unwanted leading blank space on oracle number format

前端 未结 2 1643
走了就别回头了
走了就别回头了 2021-01-17 08:36

I need to pad numbers with leading zeros (total 8 digits) for display. I\'m using oracle.

select to_char(1011,\'00000000\') OPE_NO from dual;
select length(t         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-17 09:30

    From that same documentation mentioned by EddieAwad:

    Negative return values automatically contain a leading negative sign and positive values automatically contain a leading space unless the format model contains the MI, S, or PR format element.


    EDIT: The right way is to use the FM modifier, as answered by Steve Bosman. Read the section about Format Model Modifiers for more info.

提交回复
热议问题