0

I'm trying to save decimal value in DB but getting this error.

The value I'm trying to save 0.00038711029163348665 or 1.00038711029163348665 or 2.00038711029163348665, and column in DB is Decimal(18,18) not sure what I'm doing wrong

1
  • 3
    You need to read the docs and understand precision and scale Commented Sep 18, 2019 at 1:35

2 Answers 2

3

The precision DECIMAL(18,18) means 18 total units of precision, all 18 of which come after the decimal point. You need at least one unit of precision to the left of the decimal point to handle the whole number components of the input, so you should be using DECIMAL(19,18), or something similar.

See the demo to verify that DECIMAL(19,18) resolves your problem, at least for the data you showed us.

Sign up to request clarification or add additional context in comments.

Comments

2

Decimal(18,18) has 18 digits to the right of the decimal place and none to the left, so 1.00038711029163348665 doesn't fit.

Use a larger type. Why not just use decimal(38, 18)?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.