What type used in Postgre to save a large currency field in the format of 000,000,000,000.00

Asked

Viewed 191 times

1

I am developing a web application in Asp.net and need to save a monetary value in decimal format in C# and store it in postgre in Numeric format, and the value is great. It’s a need that came up in my system... I’m wearing a field entry mask (C#):

NomeDoField.mask('000.000.000.000.000,00', { reverse: true });

I tried to set the field type in postgre to Numeric(15.2), but gives error when saving.

Forgive me for the simplicity of the question, as it is the first time I work with fields like this in C#/Postgre.

Thank you :)

1 answer

3


postgres may use a custom currency type.

The largest capacity for a custom type that we can represent of the type float (with 2 decimal places) is the following:

create table pagamento(
   id serial primary key,
   valor numeric(1000,2) --representacao maxima
);

Follow the documentation that says:

Note: The Maximum allowed Precision when explicitly specified in the type declaration is 1000; NUMERIC without a specified Precision is Subject to the Limits described in Table 8-2.

In a free translation it would be:

The maximum precision explicitly specified in the type declaration is 1000; Numeric without a specified precision is subject to the limits described in table 8-2.

Link to the table 8-2

Apart from these custom types it is still possible to use money type.

Follow the documentation for type money: https://www.postgresql.org/docs/current/datatype-money.html

  • Thanks for the help @Danizavtz!!! It worked perfectly now! I am very grateful :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.