SQL Datatype to use when inserting money

前端 未结 2 733
后悔当初
后悔当初 2021-01-05 06:15

I am using Oracle SQL database and I have to insert a monetary value(salary) as part of a row. For some strange reason the money command isnt working, is there any alternate

相关标签:
2条回答
  • 2021-01-05 06:27

    Look at this line

    salary MONEY NOT NULL
    

    There is no existing money datatype.

    If you are looking for something similar to SQL-Server small money type, you want to use a Number(10,4) and then format the number.

    You can format the number using to_char function

    select to_char(yourColumn, '$99,999.99') from yourTable where someCondition
    
    0 讨论(0)
  • 2021-01-05 06:36

    The "strange" reason is simple: There is no MONEY data type.

    The data type most appropriate for monetary values would be NUMBER (using an appropriate scale). Since it is a decimal floating-point type, it is better suited for monetary values than the binary floating-point types BINARY_FLOAT and BINARY_DOUBLE.

    Note, though, that you will still need to parse the input string £00,000.000 in your front end and send it as a numeric value to the back end.

    0 讨论(0)
提交回复
热议问题