How to always show two decimal places on a number in PL/SQL

后端 未结 1 1094
半阙折子戏
半阙折子戏 2021-01-06 06:15

Folks,

I have a existing stored procedure that I\'m trying to update to always show two decimal places even when it\'s a whole number or single decimal number.

相关标签:
1条回答
  • 2021-01-06 06:51

    You actually, have to insert the data with formatting. (Assuming the targeted column is VARCHAR) What ever format you fetch and put into a NUMBER variable, will be a NUMBER.

    A number doesn't have a format to be saved after-all. Only for display, the formatting comes into picture.

    insert into SQL_TXT values (TO_CHAR(v_credit_amt,'FM99999.00'));
    commit;
    

    If the INSERT-ed column is NUMBER again.

    You still want to go with

    SELECT TO_CHAR(COL1,'FM99999.00') FROM SQL_TEXT;
    
    0 讨论(0)
提交回复
热议问题