Oracle DB Playing Tricks On Me

Earlier at work I spent one hour trying to understand why I was unable to insert some data in a table – Oracle Database.

More specifically I was trying to insert a number value (BigDecimal(100)) from a Java application, but I always got the follow error: “ORA-01438: value larger than specified precision allowed for this column”.

I thought “Ok, let’s check the column’s properties and confront that with the value I’m trying to insert…”

The column was created with this configuration: NUMBER(15,13)

So, I thought that the first parameter was the number of digits before de decimal point, and the other parameter was the number of digits after de decimal point.

I was so wrong… =[

I’ll never insert the value 100.

That is the answer:

Optionally, you can also specify a precision (total number of digits) and scale (number of digits to the right of the decimal point):

column_name NUMBER (precision, scale)

If a precision is not specified, the column stores values as given. If no scale is specified, the scale is zero.

Link to the reference

There’s so much to learn litle padawan… =)

[]’s

Anúncios

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair / Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair / Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair / Alterar )

Foto do Google+

Você está comentando utilizando sua conta Google+. Sair / Alterar )

Conectando a %s